E boolean FDECL(snuff_candle, (struct obj *));
E boolean FDECL(snuff_lit, (struct obj *));
E boolean FDECL(catch_lit, (struct obj *));
-E void FDECL(use_unicorn_horn, (struct obj *));
+E void FDECL(use_unicorn_horn, (struct obj **));
E boolean FDECL(tinnable, (struct obj *));
E void NDECL(reset_trapset);
E void FDECL(fig_transform, (ANY_P *, long));
E void FDECL(strbuf_nl_to_crlf, (strbuf_t *));
E char *FDECL(nonconst, (const char *, char *));
E int FDECL(swapbits, (int, int, int));
+E void FDECL(shuffle_int_array, (int *, int));
/* ### insight.c ### */
}
void
-use_unicorn_horn(obj)
-struct obj *obj;
+use_unicorn_horn(optr)
+struct obj **optr;
{
#define PROP_COUNT 7 /* number of properties we're dealing with */
-#define ATTR_COUNT (A_MAX * 3) /* number of attribute points we might fix */
- int idx, val, val_limit, trouble_count, unfixable_trbl, did_prop,
- did_attr;
- int trouble_list[PROP_COUNT + ATTR_COUNT];
+ int idx, val, val_limit, trouble_count, unfixable_trbl, did_prop;
+ int trouble_list[PROP_COUNT];
+ struct obj *obj = (optr ? *optr : (struct obj *) 0);
if (obj && obj->cursed) {
long lcount = (long) rn1(90, 10);
make_stunned((HStun & TIMEOUT) + lcount, TRUE);
break;
case 4:
- (void) adjattrib(rn2(A_MAX), -1, FALSE);
+ if (Vomiting)
+ vomit();
+ else
+ make_vomiting(14L, FALSE);
break;
case 5:
(void) make_hallucinated((HHallucination & TIMEOUT) + lcount,
/*
* Entries in the trouble list use a very simple encoding scheme.
*/
-#define prop2trbl(X) ((X) + A_MAX)
-#define attr2trbl(Y) (Y)
-#define prop_trouble(X) trouble_list[trouble_count++] = prop2trbl(X)
-#define attr_trouble(Y) trouble_list[trouble_count++] = attr2trbl(Y)
+#define prop_trouble(X) trouble_list[trouble_count++] = (X)
#define TimedTrouble(P) (((P) && !((P) & ~TIMEOUT)) ? ((P) & TIMEOUT) : 0L)
- trouble_count = unfixable_trbl = did_prop = did_attr = 0;
+ trouble_count = unfixable_trbl = did_prop = 0;
/* collect property troubles */
if (TimedTrouble(Sick))
if (TimedTrouble(HDeaf))
prop_trouble(DEAF);
- unfixable_trbl = unfixable_trouble_count(TRUE);
-
- /* collect attribute troubles */
- for (idx = 0; idx < A_MAX; idx++) {
- if (ABASE(idx) >= AMAX(idx))
- continue;
- val_limit = AMAX(idx);
- /* this used to adjust 'val_limit' for A_STR when u.uhs was
- WEAK or worse, but that's handled via ATEMP(A_STR) now */
- if (Fixed_abil) {
- /* potion/spell of restore ability override sustain ability
- intrinsic but unicorn horn usage doesn't */
- unfixable_trbl += val_limit - ABASE(idx);
- continue;
- }
- /* don't recover more than 3 points worth of any attribute */
- if (val_limit > ABASE(idx) + 3)
- val_limit = ABASE(idx) + 3;
-
- for (val = ABASE(idx); val < val_limit; val++)
- attr_trouble(idx);
- /* keep track of unfixed trouble, for message adjustment below */
- unfixable_trbl += (AMAX(idx) - val_limit);
- }
-
if (trouble_count == 0) {
pline1(nothing_happens);
return;
- } else if (trouble_count > 1) { /* shuffle */
- int i, j, k;
-
- for (i = trouble_count - 1; i > 0; i--)
- if ((j = rn2(i + 1)) != i) {
- k = trouble_list[j];
- trouble_list[j] = trouble_list[i];
- trouble_list[i] = k;
- }
- }
+ } else if (trouble_count > 1)
+ shuffle_int_array(trouble_list, trouble_count);
/*
* Chances for number of troubles to be fixed
idx = trouble_list[val];
switch (idx) {
- case prop2trbl(SICK):
+ case SICK:
make_sick(0L, (char *) 0, TRUE, SICK_ALL);
did_prop++;
break;
- case prop2trbl(BLINDED):
+ case BLINDED:
make_blinded((long) u.ucreamed, TRUE);
did_prop++;
break;
- case prop2trbl(HALLUC):
+ case HALLUC:
(void) make_hallucinated(0L, TRUE, 0L);
did_prop++;
break;
- case prop2trbl(VOMITING):
+ case VOMITING:
make_vomiting(0L, TRUE);
did_prop++;
break;
- case prop2trbl(CONFUSION):
+ case CONFUSION:
make_confused(0L, TRUE);
did_prop++;
break;
- case prop2trbl(STUNNED):
+ case STUNNED:
make_stunned(0L, TRUE);
did_prop++;
break;
- case prop2trbl(DEAF):
+ case DEAF:
make_deaf(0L, TRUE);
did_prop++;
break;
default:
- if (idx >= 0 && idx < A_MAX) {
- ABASE(idx) += 1;
- did_attr++;
- } else
- panic("use_unicorn_horn: bad trouble? (%d)", idx);
+ impossible("use_unicorn_horn: bad trouble? (%d)", idx);
break;
}
}
- if (did_attr || did_prop)
+ if (did_prop)
g.context.botl = TRUE;
- if (did_attr)
- pline("This makes you feel %s!",
- (did_prop + did_attr) == (trouble_count + unfixable_trbl)
- ? "great"
- : "better");
- else if (!did_prop)
+ else
pline("Nothing seems to happen.");
#undef PROP_COUNT
-#undef ATTR_COUNT
-#undef prop2trbl
-#undef attr2trbl
#undef prop_trouble
-#undef attr_trouble
#undef TimedTrouble
}
use_figurine(&obj);
break;
case UNICORN_HORN:
- use_unicorn_horn(obj);
+ use_unicorn_horn(&obj);
break;
case WOODEN_FLUTE:
case MAGIC_FLUTE: