OSDN Git Service

add translation for enlightenment
[jnethack/source.git] / src / attrib.c
1 /* NetHack 3.6  attrib.c        $NHDT-Date: 1449269911 2015/12/04 22:58:31 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.51 $ */
2 /*      Copyright 1988, 1989, 1990, 1992, M. Stephenson           */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
8 /* JNetHack may be freely redistributed.  See license for details. */
9
10
11 /*  attribute modification routines. */
12
13 #include "hack.h"
14 #include <ctype.h>
15
16 /* part of the output on gain or loss of attribute */
17 static const char
18 #if 0 /*JP*/
19     *const plusattr[] = { "strong", "smart", "wise",
20                           "agile",  "tough", "charismatic" },
21 #else
22     *const plusattr[] = { "\8b­\82¢", "\8c«\96¾\82¾", "\8c«\82¢",
23                           "\8b@\95q\82¾", "\8aæ\8fä\82¾", "\96£\97Í\93I\82¾" },
24 #endif
25 #if 0 /*JP*/
26     *const minusattr[] = { "weak",    "stupid",
27                            "foolish", "clumsy",
28                            "fragile", "repulsive" };
29 #else
30     *const minusattr[] = { "\8eã\82¢", "\8bð\82©\82¾",
31                            "\8aÔ\94²\82¯\82¾", "\95s\8aí\97p\82¾",
32                            "\82Ð\8eã\82¾","\8fX\82¢" };
33 #endif
34
35 static const struct innate {
36     schar ulevel;
37     long *ability;
38     const char *gainstr, *losestr;
39 } arc_abil[] = { { 1, &(HStealth), "", "" },
40                  { 1, &(HFast), "", "" },
41 /*JP
42                  { 10, &(HSearching), "perceptive", "" },
43 */
44                  { 10, &(HSearching), "\92m\8ao\97Í\82ð\93¾\82½", "\92m\8ao\97Í\82ð\8e¸\82Á\82½" },
45                  { 0, 0, 0, 0 } },
46
47   bar_abil[] = { { 1, &(HPoison_resistance), "", "" },
48 /*JP
49                  { 7, &(HFast), "quick", "slow" },
50 */
51                  { 7, &(HFast), "\91f\91\81\82³\82ð\93¾\82½", "\92x\82­\82È\82Á\82½" },
52 /*JP
53                  { 15, &(HStealth), "stealthy", "" },
54 */
55                  { 15, &(HStealth), "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\93¾\82½", "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\8e¸\82Á\82½" },
56                  { 0, 0, 0, 0 } },
57
58 /*JP
59   cav_abil[] = { { 7, &(HFast), "quick", "slow" },
60 */
61   cav_abil[] = { { 7, &(HFast), "\91f\91\81\82³\82ð\93¾\82½", "\92x\82­\82È\82Á\82½" },
62 /*JP
63                  { 15, &(HWarning), "sensitive", "" },
64 */
65                  { 15, &(HWarning), "\95q\8a´\82É\82È\82Á\82½", "\93Ý\8a´\82É\82È\82Á\82½" },
66                  { 0, 0, 0, 0 } },
67
68   hea_abil[] = { { 1, &(HPoison_resistance), "", "" },
69 /*JP
70                  { 15, &(HWarning), "sensitive", "" },
71 */
72                  { 15, &(HWarning), "\95q\8a´\82É\82È\82Á\82½", "\93Ý\8a´\82É\82È\82Á\82½" },
73                  { 0, 0, 0, 0 } },
74
75 /*JP
76   kni_abil[] = { { 7, &(HFast), "quick", "slow" }, { 0, 0, 0, 0 } },
77 */
78   kni_abil[] = { { 7, &(HFast), "\91f\91\81\82³\82ð\93¾\82½", "\92x\82­\82È\82Á\82½" }, { 0, 0, 0, 0 } },
79
80   mon_abil[] = { { 1, &(HFast), "", "" },
81                  { 1, &(HSleep_resistance), "", "" },
82                  { 1, &(HSee_invisible), "", "" },
83 /*JP
84                  { 3, &(HPoison_resistance), "healthy", "" },
85 */
86                  { 3, &(HPoison_resistance), "\8c\92\8dN\82É\82È\82Á\82½", "\95s\8c\92\8dN\82É\82È\82Á\82½" },
87 /*JP
88                  { 5, &(HStealth), "stealthy", "" },
89 */
90                  { 5, &(HStealth), "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\93¾\82½", "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\8e¸\82Á\82½" },
91 /*JP
92                  { 7, &(HWarning), "sensitive", "" },
93 */
94                  { 7, &(HWarning), "\95q\8a´\82É\82È\82Á\82½", "\93Ý\8a´\82É\82È\82Á\82½" },
95 /*JP
96                  { 9, &(HSearching), "perceptive", "unaware" },
97 */
98                  { 9, &(HSearching), "\92m\8ao\97Í\82ð\93¾\82½", "\92m\8ao\97Í\82ð\8e¸\82Á\82½" },
99 /*JP
100                  { 11, &(HFire_resistance), "cool", "warmer" },
101 */
102                  { 11, &(HFire_resistance), "\97â\82½\82­\82È\82Á\82½", "\92g\82©\82­\82È\82Á\82½" },
103 /*JP
104                  { 13, &(HCold_resistance), "warm", "cooler" },
105 */
106                  { 13, &(HCold_resistance), "\92g\82©\82­\82È\82Á\82½", "\97â\82½\82­\82È\82Á\82½"},
107 /*JP
108                  { 15, &(HShock_resistance), "insulated", "conductive" },
109 */
110                  { 15, &(HShock_resistance), "\90â\89\8f\82³\82ê\82½", "\93±\93d\82³\82ê\82½" },
111 /*JP
112                  { 17, &(HTeleport_control), "controlled", "uncontrolled" },
113 */
114                  { 17, &(HTeleport_control), "\90§\8cä\97Í\82ð\93¾\82½","\90§\8cä\97Í\82ð\8e¸\82Á\82½" },
115                  { 0, 0, 0, 0 } },
116
117 /*JP
118   pri_abil[] = { { 15, &(HWarning), "sensitive", "" },
119 */
120   pri_abil[] = { { 15, &(HWarning), "\95q\8a´\82É\82È\82Á\82½", "\93Ý\8a´\82É\82È\82Á\82½" },
121 /*JP
122                  { 20, &(HFire_resistance), "cool", "warmer" },
123 */
124                  { 20, &(HFire_resistance), "\97â\82½\82­\82È\82Á\82½", "\92g\82©\82­\82È\82Á\82½" },
125                  { 0, 0, 0, 0 } },
126
127   ran_abil[] = { { 1, &(HSearching), "", "" },
128 /*JP
129                  { 7, &(HStealth), "stealthy", "" },
130 */
131                  { 7, &(HStealth), "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\93¾\82½", "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\8e¸\82Á\82½" },
132                  { 15, &(HSee_invisible), "", "" },
133                  { 0, 0, 0, 0 } },
134
135   rog_abil[] = { { 1, &(HStealth), "", "" },
136 /*JP
137                  { 10, &(HSearching), "perceptive", "" },
138 */
139                  { 10, &(HSearching), "\92m\8ao\97Í\82ð\93¾\82½", "\92m\8ao\97Í\82ð\8e¸\82Á\82½" },
140                  { 0, 0, 0, 0 } },
141
142   sam_abil[] = { { 1, &(HFast), "", "" },
143 /*JP
144                  { 15, &(HStealth), "stealthy", "" },
145 */
146                  { 15, &(HStealth), "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\93¾\82½", "\90l\96Ú\82ð\93\90\82Þ\97Í\82ð\8e¸\82Á\82½" },
147                  { 0, 0, 0, 0 } },
148
149 /*JP
150   tou_abil[] = { { 10, &(HSearching), "perceptive", "" },
151 */
152   tou_abil[] = { { 10, &(HSearching), "\92m\8ao\97Í\82ð\93¾\82½", "\92m\8ao\97Í\82ð\8e¸\82Á\82½" },
153 /*JP
154                  { 20, &(HPoison_resistance), "hardy", "" },
155 */
156                  { 20, &(HPoison_resistance), "\96Æ\89u\97Í\82ð\93¾\82½", "\96Æ\89u\97Í\82ð\8e¸\82Á\82½" },
157                  { 0, 0, 0, 0 } },
158
159   val_abil[] = { { 1, &(HCold_resistance), "", "" },
160                  { 1, &(HStealth), "", "" },
161 /*JP
162                  { 7, &(HFast), "quick", "slow" },
163 */
164                  { 7, &(HFast), "\91f\91\81\82³\82ð\93¾\82½", "\92x\82­\82È\82Á\82½" },
165                  { 0, 0, 0, 0 } },
166
167 /*JP
168   wiz_abil[] = { { 15, &(HWarning), "sensitive", "" },
169 */
170   wiz_abil[] = { { 15, &(HWarning), "\95q\8a´\82É\82È\82Á\82½", "\93Ý\8a´\82É\82È\82Á\82½" },
171 /*JP
172                  { 17, &(HTeleport_control), "controlled", "uncontrolled" },
173 */
174                  { 17, &(HTeleport_control), "\90§\8cä\97Í\82ð\93¾\82½","\90§\8cä\97Í\82ð\8e¸\82Á\82½" },
175                  { 0, 0, 0, 0 } },
176
177   /* Intrinsics conferred by race */
178 /*JP
179     elf_abil[] = { { 4, &(HSleep_resistance), "awake", "tired" },
180 */
181     elf_abil[] = { { 4, &(HSleep_resistance), "\96Ú\82ª\8ao\82ß\82½", "\96°\82­\82È\82Á\82½" },
182                    { 0, 0, 0, 0 } },
183
184   orc_abil[] = { { 1, &(HPoison_resistance), "", "" }, { 0, 0, 0, 0 } };
185
186 STATIC_DCL void NDECL(exerper);
187 STATIC_DCL void FDECL(postadjabil, (long *));
188 STATIC_DCL const struct innate *FDECL(check_innate_abil, (long *, long));
189 STATIC_DCL int FDECL(innately, (long *));
190
191 /* adjust an attribute; return TRUE if change is made, FALSE otherwise */
192 boolean
193 adjattrib(ndx, incr, msgflg)
194 int ndx, incr;
195 int msgflg; /* positive => no message, zero => message, and */
196 {           /* negative => conditional (msg if change made) */
197     int old_acurr;
198     boolean abonflg;
199     const char *attrstr;
200
201     if (Fixed_abil || !incr)
202         return FALSE;
203
204     if ((ndx == A_INT || ndx == A_WIS) && uarmh && uarmh->otyp == DUNCE_CAP) {
205         if (msgflg == 0)
206 /*JP
207             Your("cap constricts briefly, then relaxes again.");
208 */
209             Your("\96X\8eq\82ª\82µ\82Î\82ç\82­\82Ì\8aÔ\83L\83\85\82Á\82Æ\92÷\82ß\82Â\82¯\81C\82»\82µ\82Ä\82ä\82é\82ñ\82¾\81D");
210         return FALSE;
211     }
212
213     old_acurr = ACURR(ndx);
214     if (incr > 0) {
215         ABASE(ndx) += incr;
216         if (ABASE(ndx) > AMAX(ndx)) {
217             incr = ABASE(ndx) - AMAX(ndx);
218             AMAX(ndx) += incr;
219             if (AMAX(ndx) > ATTRMAX(ndx))
220                 AMAX(ndx) = ATTRMAX(ndx);
221             ABASE(ndx) = AMAX(ndx);
222         }
223         attrstr = plusattr[ndx];
224         abonflg = (ABON(ndx) < 0);
225     } else {
226         ABASE(ndx) += incr;
227         if (ABASE(ndx) < ATTRMIN(ndx)) {
228             incr = ABASE(ndx) - ATTRMIN(ndx);
229             ABASE(ndx) = ATTRMIN(ndx);
230             AMAX(ndx) += incr;
231             if (AMAX(ndx) < ATTRMIN(ndx))
232                 AMAX(ndx) = ATTRMIN(ndx);
233         }
234         attrstr = minusattr[ndx];
235         abonflg = (ABON(ndx) > 0);
236     }
237     if (ACURR(ndx) == old_acurr) {
238         if (msgflg == 0 && flags.verbose)
239 #if 0 /*JP*/
240             pline("You're %s as %s as you can get.",
241                   abonflg ? "currently" : "already", attrstr);
242 #else
243             You("%s\8f\\95ª\82É%s\81D",
244                   abonflg ? "\8d¡\82Ì\82Æ\82±\82ë" : "\8aù\82É", attrstr);
245 #endif
246         return FALSE;
247     }
248
249     if (msgflg <= 0)
250 /*JP
251         You_feel("%s%s!", (incr > 1 || incr < -1) ? "very " : "", attrstr);
252 */
253         You("%s%s\82È\82Á\82½\82æ\82¤\82È\8bC\82ª\82µ\82½\81I", (incr > 1 || incr < -1) ? "\82Æ\82Ä\82à" : "", jconj_adj(attrstr));
254     context.botl = 1;
255     if (moves > 1 && (ndx == A_STR || ndx == A_CON))
256         (void) encumber_msg();
257     return TRUE;
258 }
259
260 void
261 gainstr(otmp, incr, givemsg)
262 struct obj *otmp;
263 int incr;
264 boolean givemsg;
265 {
266     int num = incr;
267
268     if (!num) {
269         if (ABASE(A_STR) < 18)
270             num = (rn2(4) ? 1 : rnd(6));
271         else if (ABASE(A_STR) < STR18(85))
272             num = rnd(10);
273         else
274             num = 1;
275     }
276     (void) adjattrib(A_STR, (otmp && otmp->cursed) ? -num : num,
277                      givemsg ? -1 : 1);
278 }
279
280 /* may kill you; cause may be poison or monster like 'a' */
281 void
282 losestr(num)
283 register int num;
284 {
285     int ustr = ABASE(A_STR) - num;
286
287     while (ustr < 3) {
288         ++ustr;
289         --num;
290         if (Upolyd) {
291             u.mh -= 6;
292             u.mhmax -= 6;
293         } else {
294             u.uhp -= 6;
295             u.uhpmax -= 6;
296         }
297     }
298     (void) adjattrib(A_STR, -num, 1);
299 }
300
301 static const struct poison_effect_message {
302     void VDECL((*delivery_func), (const char *, ...));
303     const char *effect_msg;
304 } poiseff[] = {
305     { You_feel, "weaker" },             /* A_STR */
306     { Your, "brain is on fire" },       /* A_INT */
307     { Your, "judgement is impaired" },  /* A_WIS */
308     { Your, "muscles won't obey you" }, /* A_DEX */
309     { You_feel, "very sick" },          /* A_CON */
310     { You, "break out in hives" }       /* A_CHA */
311 };
312
313 /* feedback for attribute loss due to poisoning */
314 void
315 poisontell(typ, exclaim)
316 int typ;         /* which attribute */
317 boolean exclaim; /* emphasis */
318 {
319     void VDECL((*func), (const char *, ...)) = poiseff[typ].delivery_func;
320
321     (*func)("%s%c", poiseff[typ].effect_msg, exclaim ? '!' : '.');
322 }
323
324 /* called when an attack or trap has poisoned the hero (used to be in mon.c)
325  */
326 void
327 poisoned(reason, typ, pkiller, fatal, thrown_weapon)
328 const char *reason,    /* controls what messages we display */
329     *pkiller;          /* for score+log file if fatal */
330 int typ, fatal;        /* if fatal is 0, limit damage to adjattrib */
331 boolean thrown_weapon; /* thrown weapons are less deadly */
332 {
333     int i, loss, kprefix = KILLED_BY_AN;
334
335     /* inform player about being poisoned unless that's already been done;
336        "blast" has given a "blast of poison gas" message; "poison arrow",
337        "poison dart", etc have implicitly given poison messages too... */
338 #if 0 /*JP*/
339     if (strcmp(reason, "blast") && !strstri(reason, "poison")) {
340 #else
341     if (strcmp(reason, "\95\97") && strcmp(reason, "\91§") && !strstri(reason, "\93Å")) {
342 #endif
343 #if 0 /*JP*/
344         boolean plural = (reason[strlen(reason) - 1] == 's') ? 1 : 0;
345 #endif
346
347         /* avoid "The" Orcus's sting was poisoned... */
348 #if 0 /*JP*/
349         pline("%s%s %s poisoned!", isupper(*reason) ? "" : "The ", reason,
350               plural ? "were" : "was");
351 #else
352         pline("%s\82Í\93Å\82É\82¨\82©\82³\82ê\82Ä\82¢\82é\81I", reason);
353 #endif
354     }
355     if (Poison_resistance) {
356 #if 0 /*JP*/
357         if (!strcmp(reason, "blast"))
358 #else
359         if (!strcmp(reason, "\95\97") || !strcmp(reason, "\91§"))
360 #endif
361             shieldeff(u.ux, u.uy);
362 /*JP
363         pline_The("poison doesn't seem to affect you.");
364 */
365         pline("\93Å\82Í\8cø\82©\82È\82©\82Á\82½\82æ\82¤\82¾\81D");
366         return;
367     }
368
369 #if 0 /*JP*//*\93ú\96{\8cê\82Å\82Í\95s\97v*/
370     /* suppress killer prefix if it already has one */
371     i = name_to_mon(pkiller);
372     if (i >= LOW_PM && (mons[i].geno & G_UNIQ)) {
373         kprefix = KILLED_BY;
374         if (!type_is_pname(&mons[i]))
375             pkiller = the(pkiller);
376     } else if (!strncmpi(pkiller, "the ", 4) || !strncmpi(pkiller, "an ", 3)
377                || !strncmpi(pkiller, "a ", 2)) {
378         /*[ does this need a plural check too? ]*/
379         kprefix = KILLED_BY;
380     }
381 #endif
382
383     i = !fatal ? 1 : rn2(fatal + (thrown_weapon ? 20 : 0));
384     if (i == 0 && typ != A_CHA) {
385         /* instant kill */
386         u.uhp = -1;
387 /*JP
388         pline_The("poison was deadly...");
389 */
390         pline("\93Å\82Í\92v\8e\80\97Ê\82¾\82Á\82½\81D\81D\81D");
391     } else if (i > 5) {
392         /* HP damage; more likely--but less severe--with missiles */
393         loss = thrown_weapon ? rnd(6) : rn1(10, 6);
394         losehp(loss, pkiller, kprefix); /* poison damage */
395     } else {
396         /* attribute loss; if typ is A_STR, reduction in current and
397            maximum HP will occur once strength has dropped down to 3 */
398         loss = (thrown_weapon || !fatal) ? 1 : d(2, 2); /* was rn1(3,3) */
399         /* check that a stat change was made */
400         if (adjattrib(typ, -loss, 1))
401             poisontell(typ, TRUE);
402     }
403
404     if (u.uhp < 1) {
405         killer.format = kprefix;
406         Strcpy(killer.name, pkiller);
407 #if 0 /*JP*/
408         /* "Poisoned by a poisoned ___" is redundant */
409         done(strstri(pkiller, "poison") ? DIED : POISONING);
410 #else /*JP:\93ú\96{\8cê\82Å\82Í\8bæ\95Ê\82µ\82Ä\82¢\82È\82¢*/
411         done(POISONING);
412 #endif
413     }
414     (void) encumber_msg();
415 }
416
417 void
418 change_luck(n)
419 register schar n;
420 {
421     u.uluck += n;
422     if (u.uluck < 0 && u.uluck < LUCKMIN)
423         u.uluck = LUCKMIN;
424     if (u.uluck > 0 && u.uluck > LUCKMAX)
425         u.uluck = LUCKMAX;
426 }
427
428 int
429 stone_luck(parameter)
430 boolean parameter; /* So I can't think up of a good name.  So sue me. --KAA */
431 {
432     register struct obj *otmp;
433     register long bonchance = 0;
434
435     for (otmp = invent; otmp; otmp = otmp->nobj)
436         if (confers_luck(otmp)) {
437             if (otmp->cursed)
438                 bonchance -= otmp->quan;
439             else if (otmp->blessed)
440                 bonchance += otmp->quan;
441             else if (parameter)
442                 bonchance += otmp->quan;
443         }
444
445     return sgn((int) bonchance);
446 }
447
448 /* there has just been an inventory change affecting a luck-granting item */
449 void
450 set_moreluck()
451 {
452     int luckbon = stone_luck(TRUE);
453
454     if (!luckbon && !carrying(LUCKSTONE))
455         u.moreluck = 0;
456     else if (luckbon >= 0)
457         u.moreluck = LUCKADD;
458     else
459         u.moreluck = -LUCKADD;
460 }
461
462 void
463 restore_attrib()
464 {
465     int i;
466
467     for (i = 0; i < A_MAX; i++) { /* all temporary losses/gains */
468
469         if (ATEMP(i) && ATIME(i)) {
470             if (!(--(ATIME(i)))) { /* countdown for change */
471                 ATEMP(i) += ATEMP(i) > 0 ? -1 : 1;
472
473                 if (ATEMP(i)) /* reset timer */
474                     ATIME(i) = 100 / ACURR(A_CON);
475             }
476         }
477     }
478     (void) encumber_msg();
479 }
480
481 #define AVAL 50 /* tune value for exercise gains */
482
483 void
484 exercise(i, inc_or_dec)
485 int i;
486 boolean inc_or_dec;
487 {
488     debugpline0("Exercise:");
489     if (i == A_INT || i == A_CHA)
490         return; /* can't exercise these */
491
492     /* no physical exercise while polymorphed; the body's temporary */
493     if (Upolyd && i != A_WIS)
494         return;
495
496     if (abs(AEXE(i)) < AVAL) {
497         /*
498          *      Law of diminishing returns (Part I):
499          *
500          *      Gain is harder at higher attribute values.
501          *      79% at "3" --> 0% at "18"
502          *      Loss is even at all levels (50%).
503          *
504          *      Note: *YES* ACURR is the right one to use.
505          */
506         AEXE(i) += (inc_or_dec) ? (rn2(19) > ACURR(i)) : -rn2(2);
507         debugpline3("%s, %s AEXE = %d",
508                     (i == A_STR) ? "Str" : (i == A_WIS) ? "Wis" : (i == A_DEX)
509                                                                       ? "Dex"
510                                                                       : "Con",
511                     (inc_or_dec) ? "inc" : "dec", AEXE(i));
512     }
513     if (moves > 0 && (i == A_STR || i == A_CON))
514         (void) encumber_msg();
515 }
516
517 STATIC_OVL void
518 exerper()
519 {
520     if (!(moves % 10)) {
521         /* Hunger Checks */
522
523         int hs = (u.uhunger > 1000) ? SATIATED : (u.uhunger > 150)
524                                                      ? NOT_HUNGRY
525                                                      : (u.uhunger > 50)
526                                                            ? HUNGRY
527                                                            : (u.uhunger > 0)
528                                                                  ? WEAK
529                                                                  : FAINTING;
530
531         debugpline0("exerper: Hunger checks");
532         switch (hs) {
533         case SATIATED:
534             exercise(A_DEX, FALSE);
535             if (Role_if(PM_MONK))
536                 exercise(A_WIS, FALSE);
537             break;
538         case NOT_HUNGRY:
539             exercise(A_CON, TRUE);
540             break;
541         case WEAK:
542             exercise(A_STR, FALSE);
543             if (Role_if(PM_MONK)) /* fasting */
544                 exercise(A_WIS, TRUE);
545             break;
546         case FAINTING:
547         case FAINTED:
548             exercise(A_CON, FALSE);
549             break;
550         }
551
552         /* Encumbrance Checks */
553         debugpline0("exerper: Encumber checks");
554         switch (near_capacity()) {
555         case MOD_ENCUMBER:
556             exercise(A_STR, TRUE);
557             break;
558         case HVY_ENCUMBER:
559             exercise(A_STR, TRUE);
560             exercise(A_DEX, FALSE);
561             break;
562         case EXT_ENCUMBER:
563             exercise(A_DEX, FALSE);
564             exercise(A_CON, FALSE);
565             break;
566         }
567     }
568
569     /* status checks */
570     if (!(moves % 5)) {
571         debugpline0("exerper: Status checks");
572         if ((HClairvoyant & (INTRINSIC | TIMEOUT)) && !BClairvoyant)
573             exercise(A_WIS, TRUE);
574         if (HRegeneration)
575             exercise(A_STR, TRUE);
576
577         if (Sick || Vomiting)
578             exercise(A_CON, FALSE);
579         if (Confusion || Hallucination)
580             exercise(A_WIS, FALSE);
581         if ((Wounded_legs && !u.usteed) || Fumbling || HStun)
582             exercise(A_DEX, FALSE);
583     }
584 }
585
586 /* exercise/abuse text (must be in attribute order, not botl order);
587    phrased as "You must have been [][0]." or "You haven't been [][1]." */
588 static NEARDATA const char *const exertext[A_MAX][2] = {
589 #if 0 /*JP*/
590     { "exercising diligently", "exercising properly" },           /* Str */
591     { 0, 0 },                                                     /* Int */
592     { "very observant", "paying attention" },                     /* Wis */
593     { "working on your reflexes", "working on reflexes lately" }, /* Dex */
594     { "leading a healthy life-style", "watching your health" },   /* Con */
595     { 0, 0 },                                                     /* Cha */
596 #else
597     { "\94O\93ü\82è\82É\89^\93®\82µ\82Ä\82¢\82½", "\93K\90Ø\82É\89^\93®\82µ\82Ä\82¢\82È\82©\82Á\82½" },       /* Str */
598     { 0, 0 },                                                     /* Int */
599     { "\90T\8fd\82É\8ds\93®\82µ\82Ä\82¢\82½", "\92\8d\88Ó\95s\91«\82¾\82Á\82½" },                   /* Wis */
600     { "\94½\8eË\90_\8co\82ð\8eg\82Á\82Ä\82¢\82½", "\8dÅ\8bß\94½\8eË\90_\8co\82ð\8eg\82Á\82Ä\82¢\82È\82©\82Á\82½" }, /* Dex */
601     { "\8c\92\8dN\93I\82È\90\8a\88\82ð\82µ\82Ä\82¢\82½", "\8c\92\8dN\8aÇ\97\9d\82ð\91Ó\82Á\82Ä\82¢\82½" },         /* Con */
602     { 0, 0 },                                                     /* Cha */
603 #endif
604 };
605
606 void
607 exerchk()
608 {
609     int i, ax, mod_val, lolim, hilim;
610
611     /*  Check out the periodic accumulations */
612     exerper();
613
614     if (moves >= context.next_attrib_check) {
615         debugpline1("exerchk: ready to test. multi = %d.", multi);
616     }
617     /*  Are we ready for a test? */
618     if (moves >= context.next_attrib_check && !multi) {
619         debugpline0("exerchk: testing.");
620         /*
621          *      Law of diminishing returns (Part II):
622          *
623          *      The effects of "exercise" and "abuse" wear
624          *      off over time.  Even if you *don't* get an
625          *      increase/decrease, you lose some of the
626          *      accumulated effects.
627          */
628         for (i = 0; i < A_MAX; ++i) {
629             ax = AEXE(i);
630             /* nothing to do here if no exercise or abuse has occurred
631                (Int and Cha always fall into this category) */
632             if (!ax)
633                 continue; /* ok to skip nextattrib */
634
635             mod_val = sgn(ax); /* +1 or -1; used below */
636             /* no further effect for exercise if at max or abuse if at min;
637                can't exceed 18 via exercise even if actual max is higher */
638             lolim = ATTRMIN(i); /* usually 3; might be higher */
639             hilim = ATTRMAX(i); /* usually 18; maybe lower or higher */
640             if (hilim > 18)
641                 hilim = 18;
642             if ((ax < 0) ? (ABASE(i) <= lolim) : (ABASE(i) >= hilim))
643                 goto nextattrib;
644             /* can't exercise non-Wisdom while polymorphed; previous
645                exercise/abuse gradually wears off without impact then */
646             if (Upolyd && i != A_WIS)
647                 goto nextattrib;
648
649             debugpline2("exerchk: testing %s (%d).",
650                         (i == A_STR)
651                             ? "Str"
652                             : (i == A_INT)
653                                   ? "Int?"
654                                   : (i == A_WIS)
655                                         ? "Wis"
656                                         : (i == A_DEX)
657                                               ? "Dex"
658                                               : (i == A_CON)
659                                                     ? "Con"
660                                                     : (i == A_CHA)
661                                                           ? "Cha?"
662                                                           : "???",
663                         ax);
664             /*
665              *  Law of diminishing returns (Part III):
666              *
667              *  You don't *always* gain by exercising.
668              *  [MRS 92/10/28 - Treat Wisdom specially for balance.]
669              */
670             if (rn2(AVAL) > ((i != A_WIS) ? (abs(ax) * 2 / 3) : abs(ax)))
671                 goto nextattrib;
672
673             debugpline1("exerchk: changing %d.", i);
674             if (adjattrib(i, mod_val, -1)) {
675                 debugpline1("exerchk: changed %d.", i);
676                 /* if you actually changed an attrib - zero accumulation */
677                 AEXE(i) = ax = 0;
678                 /* then print an explanation */
679 #if 0 /*JP*/
680                 You("%s %s.",
681                     (mod_val > 0) ? "must have been" : "haven't been",
682                     exertext[i][(mod_val > 0) ? 0 : 1]);
683 #else
684                 You("%s\82É\88á\82¢\82È\82¢\81D",
685                     exertext[i][(mod_val > 0) ? 0 : 1]);
686 #endif
687             }
688         nextattrib:
689             /* this used to be ``AEXE(i) /= 2'' but that would produce
690                platform-dependent rounding/truncation for negative vals */
691             AEXE(i) = (abs(ax) / 2) * mod_val;
692         }
693         context.next_attrib_check += rn1(200, 800);
694         debugpline1("exerchk: next check at %ld.", context.next_attrib_check);
695     }
696 }
697
698 void
699 init_attr(np)
700 register int np;
701 {
702     register int i, x, tryct;
703
704     for (i = 0; i < A_MAX; i++) {
705         ABASE(i) = AMAX(i) = urole.attrbase[i];
706         ATEMP(i) = ATIME(i) = 0;
707         np -= urole.attrbase[i];
708     }
709
710     tryct = 0;
711     while (np > 0 && tryct < 100) {
712         x = rn2(100);
713         for (i = 0; (i < A_MAX) && ((x -= urole.attrdist[i]) > 0); i++)
714             ;
715         if (i >= A_MAX)
716             continue; /* impossible */
717
718         if (ABASE(i) >= ATTRMAX(i)) {
719             tryct++;
720             continue;
721         }
722         tryct = 0;
723         ABASE(i)++;
724         AMAX(i)++;
725         np--;
726     }
727
728     tryct = 0;
729     while (np < 0 && tryct < 100) { /* for redistribution */
730
731         x = rn2(100);
732         for (i = 0; (i < A_MAX) && ((x -= urole.attrdist[i]) > 0); i++)
733             ;
734         if (i >= A_MAX)
735             continue; /* impossible */
736
737         if (ABASE(i) <= ATTRMIN(i)) {
738             tryct++;
739             continue;
740         }
741         tryct = 0;
742         ABASE(i)--;
743         AMAX(i)--;
744         np++;
745     }
746 }
747
748 void
749 redist_attr()
750 {
751     register int i, tmp;
752
753     for (i = 0; i < A_MAX; i++) {
754         if (i == A_INT || i == A_WIS)
755             continue;
756         /* Polymorphing doesn't change your mind */
757         tmp = AMAX(i);
758         AMAX(i) += (rn2(5) - 2);
759         if (AMAX(i) > ATTRMAX(i))
760             AMAX(i) = ATTRMAX(i);
761         if (AMAX(i) < ATTRMIN(i))
762             AMAX(i) = ATTRMIN(i);
763         ABASE(i) = ABASE(i) * AMAX(i) / tmp;
764         /* ABASE(i) > ATTRMAX(i) is impossible */
765         if (ABASE(i) < ATTRMIN(i))
766             ABASE(i) = ATTRMIN(i);
767     }
768     (void) encumber_msg();
769 }
770
771 STATIC_OVL
772 void
773 postadjabil(ability)
774 long *ability;
775 {
776     if (!ability)
777         return;
778     if (ability == &(HWarning) || ability == &(HSee_invisible))
779         see_monsters();
780 }
781
782 STATIC_OVL const struct innate *
783 check_innate_abil(ability, frommask)
784 long *ability;
785 long frommask;
786 {
787     const struct innate *abil = 0;
788
789     if (frommask == FROMEXPER)
790         switch (Role_switch) {
791         case PM_ARCHEOLOGIST:
792             abil = arc_abil;
793             break;
794         case PM_BARBARIAN:
795             abil = bar_abil;
796             break;
797         case PM_CAVEMAN:
798             abil = cav_abil;
799             break;
800         case PM_HEALER:
801             abil = hea_abil;
802             break;
803         case PM_KNIGHT:
804             abil = kni_abil;
805             break;
806         case PM_MONK:
807             abil = mon_abil;
808             break;
809         case PM_PRIEST:
810             abil = pri_abil;
811             break;
812         case PM_RANGER:
813             abil = ran_abil;
814             break;
815         case PM_ROGUE:
816             abil = rog_abil;
817             break;
818         case PM_SAMURAI:
819             abil = sam_abil;
820             break;
821         case PM_TOURIST:
822             abil = tou_abil;
823             break;
824         case PM_VALKYRIE:
825             abil = val_abil;
826             break;
827         case PM_WIZARD:
828             abil = wiz_abil;
829             break;
830         default:
831             break;
832         }
833     else if (frommask == FROMRACE)
834         switch (Race_switch) {
835         case PM_ELF:
836             abil = elf_abil;
837             break;
838         case PM_ORC:
839             abil = orc_abil;
840             break;
841         case PM_HUMAN:
842         case PM_DWARF:
843         case PM_GNOME:
844         default:
845             break;
846         }
847
848     while (abil && abil->ability) {
849         if ((abil->ability == ability) && (u.ulevel >= abil->ulevel))
850             return abil;
851         abil++;
852     }
853     return (struct innate *) 0;
854 }
855
856 /*
857  * returns 1 if FROMRACE or FROMEXPER and exper level == 1
858  * returns 2 if FROMEXPER and exper level > 1
859  * otherwise returns 0
860  */
861 STATIC_OVL int
862 innately(ability)
863 long *ability;
864 {
865     const struct innate *iptr;
866
867     if ((iptr = check_innate_abil(ability, FROMRACE)) != 0)
868         return 1;
869     else if ((iptr = check_innate_abil(ability, FROMEXPER)) != 0)
870         return (iptr->ulevel == 1) ? 1 : 2;
871     return 0;
872 }
873
874 int
875 is_innate(propidx)
876 int propidx;
877 {
878     if (propidx == BLINDED && !haseyes(youmonst.data))
879         return 1;
880     return innately(&u.uprops[propidx].intrinsic);
881 }
882
883 char *
884 from_what(propidx)
885 int propidx; /* special cases can have negative values */
886 {
887     static char buf[BUFSZ];
888
889     buf[0] = '\0';
890     /*
891      * Restrict the source of the attributes just to debug mode for now
892      */
893 /*JP:\81u\82 \82È\82½\82Í\82 \82È\82½\82Ì\81c\82É\82æ\82Á\82Ä\81v\82Æ\82È\82é\82Æ\95s\8e©\91R\82È\82Ì\82Åsimpleonames()\82ð\8eg\82¤*/
894 /*JP: \96{\97\88\82Íminimal_xname()\82ð\8eg\82¤\82×\82«\82¾\82ªstatic\82È\82Ì\82Å\91ã\97p*/
895     if (wizard) {
896 /*JP
897         static NEARDATA const char because_of[] = " because of %s";
898 */
899         static NEARDATA const char because_of[] = "%s\82É\82æ\82Á\82Ä";
900
901         if (propidx >= 0) {
902             char *p;
903             struct obj *obj = (struct obj *) 0;
904             int innate = is_innate(propidx);
905
906             if (innate == 2)
907 /*JP
908                 Strcpy(buf, " because of your experience");
909 */
910                 Strcpy(buf, "\8co\8c±\82É\82æ\82Á\82Ä");
911             else if (innate == 1)
912 /*JP
913                 Strcpy(buf, " innately");
914 */
915                 Strcpy(buf, "\90\82Ü\82ê\82È\82ª\82ç\82É");
916             else if (wizard
917                      && (obj = what_gives(&u.uprops[propidx].extrinsic)))
918                 Sprintf(buf, because_of, obj->oartifact
919                                              ? bare_artifactname(obj)
920 /*JP
921                                              : ysimple_name(obj));
922 */
923                                              : simpleonames(obj));
924             else if (propidx == BLINDED && u.uroleplay.blind)
925 /*JP
926                 Sprintf(buf, " from birth");
927 */
928                 Sprintf(buf, "\90\82Ü\82ê\82Ä\82©\82ç\82¸\82Á\82Æ");
929             else if (propidx == BLINDED && Blindfolded_only)
930 /*JP
931                 Sprintf(buf, because_of, ysimple_name(ublindf));
932 */
933                 Sprintf(buf, because_of, simpleonames(ublindf));
934
935 #if 0 /*JP*//*\95s\97v*/
936             /* remove some verbosity and/or redundancy */
937             if ((p = strstri(buf, " pair of ")) != 0)
938                 copynchars(p + 1, p + 9, BUFSZ); /* overlapping buffers ok */
939             else if (propidx == STRANGLED
940                      && (p = strstri(buf, " of strangulation")) != 0)
941                 *p = '\0';
942 #endif
943
944         } else { /* negative property index */
945             /* if more blocking capabilities get implemented we'll need to
946                replace this with what_blocks() comparable to what_gives() */
947             switch (-propidx) {
948             case BLINDED:
949                 if (ublindf
950                     && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD)
951                     Sprintf(buf, because_of, bare_artifactname(ublindf));
952                 break;
953             case INVIS:
954                 if (u.uprops[INVIS].blocked & W_ARMC)
955                     Sprintf(buf, because_of,
956 #if 0 /*JP*/
957                             ysimple_name(uarmc)); /* mummy wrapping */
958 #else
959                             simpleonames(uarmc)); /* mummy wrapping */
960 #endif
961                 break;
962             case CLAIRVOYANT:
963                 if (wizard && (u.uprops[CLAIRVOYANT].blocked & W_ARMH))
964                     Sprintf(buf, because_of,
965 #if 0 /*JP*/
966                             ysimple_name(uarmh)); /* cornuthaum */
967 #else
968                             simpleonames(uarmh)); /* cornuthaum */
969 #endif
970                 break;
971             }
972         }
973
974     } /*wizard*/
975     return buf;
976 }
977
978 void
979 adjabil(oldlevel, newlevel)
980 int oldlevel, newlevel;
981 {
982     register const struct innate *abil, *rabil;
983     long prevabil, mask = FROMEXPER;
984
985     switch (Role_switch) {
986     case PM_ARCHEOLOGIST:
987         abil = arc_abil;
988         break;
989     case PM_BARBARIAN:
990         abil = bar_abil;
991         break;
992     case PM_CAVEMAN:
993         abil = cav_abil;
994         break;
995     case PM_HEALER:
996         abil = hea_abil;
997         break;
998     case PM_KNIGHT:
999         abil = kni_abil;
1000         break;
1001     case PM_MONK:
1002         abil = mon_abil;
1003         break;
1004     case PM_PRIEST:
1005         abil = pri_abil;
1006         break;
1007     case PM_RANGER:
1008         abil = ran_abil;
1009         break;
1010     case PM_ROGUE:
1011         abil = rog_abil;
1012         break;
1013     case PM_SAMURAI:
1014         abil = sam_abil;
1015         break;
1016     case PM_TOURIST:
1017         abil = tou_abil;
1018         break;
1019     case PM_VALKYRIE:
1020         abil = val_abil;
1021         break;
1022     case PM_WIZARD:
1023         abil = wiz_abil;
1024         break;
1025     default:
1026         abil = 0;
1027         break;
1028     }
1029
1030     switch (Race_switch) {
1031     case PM_ELF:
1032         rabil = elf_abil;
1033         break;
1034     case PM_ORC:
1035         rabil = orc_abil;
1036         break;
1037     case PM_HUMAN:
1038     case PM_DWARF:
1039     case PM_GNOME:
1040     default:
1041         rabil = 0;
1042         break;
1043     }
1044
1045     while (abil || rabil) {
1046         /* Have we finished with the intrinsics list? */
1047         if (!abil || !abil->ability) {
1048             /* Try the race intrinsics */
1049             if (!rabil || !rabil->ability)
1050                 break;
1051             abil = rabil;
1052             rabil = 0;
1053             mask = FROMRACE;
1054         }
1055         prevabil = *(abil->ability);
1056         if (oldlevel < abil->ulevel && newlevel >= abil->ulevel) {
1057             /* Abilities gained at level 1 can never be lost
1058              * via level loss, only via means that remove _any_
1059              * sort of ability.  A "gain" of such an ability from
1060              * an outside source is devoid of meaning, so we set
1061              * FROMOUTSIDE to avoid such gains.
1062              */
1063             if (abil->ulevel == 1)
1064                 *(abil->ability) |= (mask | FROMOUTSIDE);
1065             else
1066                 *(abil->ability) |= mask;
1067             if (!(*(abil->ability) & INTRINSIC & ~mask)) {
1068                 if (*(abil->gainstr))
1069                     You_feel("%s!", abil->gainstr);
1070             }
1071         } else if (oldlevel >= abil->ulevel && newlevel < abil->ulevel) {
1072             *(abil->ability) &= ~mask;
1073             if (!(*(abil->ability) & INTRINSIC)) {
1074                 if (*(abil->losestr))
1075                     You_feel("%s!", abil->losestr);
1076                 else if (*(abil->gainstr))
1077                     You_feel("less %s!", abil->gainstr);
1078             }
1079         }
1080         if (prevabil != *(abil->ability)) /* it changed */
1081             postadjabil(abil->ability);
1082         abil++;
1083     }
1084
1085     if (oldlevel > 0) {
1086         if (newlevel > oldlevel)
1087             add_weapon_skill(newlevel - oldlevel);
1088         else
1089             lose_weapon_skill(oldlevel - newlevel);
1090     }
1091 }
1092
1093 int
1094 newhp()
1095 {
1096     int hp, conplus;
1097
1098     if (u.ulevel == 0) {
1099         /* Initialize hit points */
1100         hp = urole.hpadv.infix + urace.hpadv.infix;
1101         if (urole.hpadv.inrnd > 0)
1102             hp += rnd(urole.hpadv.inrnd);
1103         if (urace.hpadv.inrnd > 0)
1104             hp += rnd(urace.hpadv.inrnd);
1105         if (moves <= 1L) { /* initial hero; skip for polyself to new man */
1106             /* Initialize alignment stuff */
1107             u.ualign.type = aligns[flags.initalign].value;
1108             u.ualign.record = urole.initrecord;
1109         }
1110         /* no Con adjustment for initial hit points */
1111     } else {
1112         if (u.ulevel < urole.xlev) {
1113             hp = urole.hpadv.lofix + urace.hpadv.lofix;
1114             if (urole.hpadv.lornd > 0)
1115                 hp += rnd(urole.hpadv.lornd);
1116             if (urace.hpadv.lornd > 0)
1117                 hp += rnd(urace.hpadv.lornd);
1118         } else {
1119             hp = urole.hpadv.hifix + urace.hpadv.hifix;
1120             if (urole.hpadv.hirnd > 0)
1121                 hp += rnd(urole.hpadv.hirnd);
1122             if (urace.hpadv.hirnd > 0)
1123                 hp += rnd(urace.hpadv.hirnd);
1124         }
1125         if (ACURR(A_CON) <= 3)
1126             conplus = -2;
1127         else if (ACURR(A_CON) <= 6)
1128             conplus = -1;
1129         else if (ACURR(A_CON) <= 14)
1130             conplus = 0;
1131         else if (ACURR(A_CON) <= 16)
1132             conplus = 1;
1133         else if (ACURR(A_CON) == 17)
1134             conplus = 2;
1135         else if (ACURR(A_CON) == 18)
1136             conplus = 3;
1137         else
1138             conplus = 4;
1139         hp += conplus;
1140     }
1141     if (hp <= 0)
1142         hp = 1;
1143     if (u.ulevel < MAXULEV)
1144         u.uhpinc[u.ulevel] = (xchar) hp;
1145     return hp;
1146 }
1147
1148 schar
1149 acurr(x)
1150 int x;
1151 {
1152     register int tmp = (u.abon.a[x] + u.atemp.a[x] + u.acurr.a[x]);
1153
1154     if (x == A_STR) {
1155         if (tmp >= 125 || (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER))
1156             return (schar) 125;
1157         else
1158 #ifdef WIN32_BUG
1159             return (x = ((tmp <= 3) ? 3 : tmp));
1160 #else
1161         return (schar) ((tmp <= 3) ? 3 : tmp);
1162 #endif
1163     } else if (x == A_CHA) {
1164         if (tmp < 18
1165             && (youmonst.data->mlet == S_NYMPH || u.umonnum == PM_SUCCUBUS
1166                 || u.umonnum == PM_INCUBUS))
1167             return (schar) 18;
1168     } else if (x == A_INT || x == A_WIS) {
1169         /* yes, this may raise int/wis if player is sufficiently
1170          * stupid.  there are lower levels of cognition than "dunce".
1171          */
1172         if (uarmh && uarmh->otyp == DUNCE_CAP)
1173             return (schar) 6;
1174     }
1175 #ifdef WIN32_BUG
1176     return (x = ((tmp >= 25) ? 25 : (tmp <= 3) ? 3 : tmp));
1177 #else
1178     return (schar) ((tmp >= 25) ? 25 : (tmp <= 3) ? 3 : tmp);
1179 #endif
1180 }
1181
1182 /* condense clumsy ACURR(A_STR) value into value that fits into game formulas
1183  */
1184 schar
1185 acurrstr()
1186 {
1187     register int str = ACURR(A_STR);
1188
1189     if (str <= 18)
1190         return (schar) str;
1191     if (str <= 121)
1192         return (schar) (19 + str / 50); /* map to 19..21 */
1193     else
1194         return (schar) (min(str, 125) - 100); /* 22..25 */
1195 }
1196
1197 /* when wearing (or taking off) an unID'd item, this routine is used
1198    to distinguish between observable +0 result and no-visible-effect
1199    due to an attribute not being able to exceed maximum or minimum */
1200 boolean
1201 extremeattr(attrindx) /* does attrindx's value match its max or min? */
1202 int attrindx;
1203 {
1204     /* Fixed_abil and racial MINATTR/MAXATTR aren't relevant here */
1205     int lolimit = 3, hilimit = 25, curval = ACURR(attrindx);
1206
1207     /* upper limit for Str is 25 but its value is encoded differently */
1208     if (attrindx == A_STR) {
1209         hilimit = STR19(25); /* 125 */
1210         /* lower limit for Str can also be 25 */
1211         if (uarmg && uarmg->otyp == GAUNTLETS_OF_POWER)
1212             lolimit = hilimit;
1213     }
1214     /* this exception is hypothetical; the only other worn item affecting
1215        Int or Wis is another helmet so can't be in use at the same time */
1216     if (attrindx == A_INT || attrindx == A_WIS) {
1217         if (uarmh && uarmh->otyp == DUNCE_CAP)
1218             hilimit = lolimit = 6;
1219     }
1220
1221     /* are we currently at either limit? */
1222     return (curval == lolimit || curval == hilimit) ? TRUE : FALSE;
1223 }
1224
1225 /* avoid possible problems with alignment overflow, and provide a centralized
1226    location for any future alignment limits */
1227 void
1228 adjalign(n)
1229 int n;
1230 {
1231     int newalign = u.ualign.record + n;
1232
1233     if (n < 0) {
1234         if (newalign < u.ualign.record)
1235             u.ualign.record = newalign;
1236     } else if (newalign > u.ualign.record) {
1237         u.ualign.record = newalign;
1238         if (u.ualign.record > ALIGNLIM)
1239             u.ualign.record = ALIGNLIM;
1240     }
1241 }
1242
1243 /* change hero's alignment type, possibly losing use of artifacts */
1244 void
1245 uchangealign(newalign, reason)
1246 int newalign;
1247 int reason; /* 0==conversion, 1==helm-of-OA on, 2==helm-of-OA off */
1248 {
1249     aligntyp oldalign = u.ualign.type;
1250
1251     u.ublessed = 0;   /* lose divine protection */
1252     context.botl = 1; /* status line needs updating */
1253     if (reason == 0) {
1254         /* conversion via altar */
1255         u.ualignbase[A_CURRENT] = (aligntyp) newalign;
1256         /* worn helm of opposite alignment might block change */
1257         if (!uarmh || uarmh->otyp != HELM_OF_OPPOSITE_ALIGNMENT)
1258             u.ualign.type = u.ualignbase[A_CURRENT];
1259         You("have a %ssense of a new direction.",
1260             (u.ualign.type != oldalign) ? "sudden " : "");
1261     } else {
1262         /* putting on or taking off a helm of opposite alignment */
1263         u.ualign.type = (aligntyp) newalign;
1264         if (reason == 1)
1265             Your("mind oscillates %s.", Hallucination ? "wildly" : "briefly");
1266         else if (reason == 2)
1267             Your("mind is %s.", Hallucination
1268                                     ? "much of a muchness"
1269                                     : "back in sync with your body");
1270     }
1271
1272     if (u.ualign.type != oldalign) {
1273         u.ualign.record = 0; /* slate is wiped clean */
1274         retouch_equipment(0);
1275     }
1276 }
1277
1278 /*attrib.c*/