@@ -1931,14 +1931,13 @@ struct obj *obj;
19311931}
19321932
19331933void
1934- use_unicorn_horn (obj )
1935- struct obj * obj ;
1934+ use_unicorn_horn (optr )
1935+ struct obj * * optr ;
19361936{
19371937#define PROP_COUNT 7 /* number of properties we're dealing with */
1938- #define ATTR_COUNT (A_MAX * 3) /* number of attribute points we might fix */
1939- int idx , val , val_limit , trouble_count , unfixable_trbl , did_prop ,
1940- did_attr ;
1941- int trouble_list [PROP_COUNT + ATTR_COUNT ];
1938+ int idx , val , val_limit , trouble_count , unfixable_trbl , did_prop ;
1939+ int trouble_list [PROP_COUNT ];
1940+ struct obj * obj = (optr ? * optr : (struct obj * ) 0 );
19421941
19431942 if (obj && obj -> cursed ) {
19441943 long lcount = (long ) rn1 (90 , 10 );
@@ -1962,7 +1961,10 @@ struct obj *obj;
19621961 make_stunned ((HStun & TIMEOUT ) + lcount , TRUE);
19631962 break ;
19641963 case 4 :
1965- (void ) adjattrib (rn2 (A_MAX ), -1 , FALSE);
1964+ if (Vomiting )
1965+ vomit ();
1966+ else
1967+ make_vomiting (14L , FALSE);
19661968 break ;
19671969 case 5 :
19681970 (void ) make_hallucinated ((HHallucination & TIMEOUT ) + lcount ,
@@ -1980,13 +1982,10 @@ struct obj *obj;
19801982/*
19811983 * Entries in the trouble list use a very simple encoding scheme.
19821984 */
1983- #define prop2trbl (X ) ((X) + A_MAX)
1984- #define attr2trbl (Y ) (Y)
1985- #define prop_trouble (X ) trouble_list[trouble_count++] = prop2trbl(X)
1986- #define attr_trouble (Y ) trouble_list[trouble_count++] = attr2trbl(Y)
1985+ #define prop_trouble (X ) trouble_list[trouble_count++] = (X)
19871986#define TimedTrouble (P ) (((P) && !((P) & ~TIMEOUT)) ? ((P) & TIMEOUT) : 0L)
19881987
1989- trouble_count = unfixable_trbl = did_prop = did_attr = 0 ;
1988+ trouble_count = unfixable_trbl = did_prop = 0 ;
19901989
19911990 /* collect property troubles */
19921991 if (TimedTrouble (Sick ))
@@ -2006,44 +2005,11 @@ struct obj *obj;
20062005 if (TimedTrouble (HDeaf ))
20072006 prop_trouble (DEAF );
20082007
2009- unfixable_trbl = unfixable_trouble_count (TRUE);
2010-
2011- /* collect attribute troubles */
2012- for (idx = 0 ; idx < A_MAX ; idx ++ ) {
2013- if (ABASE (idx ) >= AMAX (idx ))
2014- continue ;
2015- val_limit = AMAX (idx );
2016- /* this used to adjust 'val_limit' for A_STR when u.uhs was
2017- WEAK or worse, but that's handled via ATEMP(A_STR) now */
2018- if (Fixed_abil ) {
2019- /* potion/spell of restore ability override sustain ability
2020- intrinsic but unicorn horn usage doesn't */
2021- unfixable_trbl += val_limit - ABASE (idx );
2022- continue ;
2023- }
2024- /* don't recover more than 3 points worth of any attribute */
2025- if (val_limit > ABASE (idx ) + 3 )
2026- val_limit = ABASE (idx ) + 3 ;
2027-
2028- for (val = ABASE (idx ); val < val_limit ; val ++ )
2029- attr_trouble (idx );
2030- /* keep track of unfixed trouble, for message adjustment below */
2031- unfixable_trbl += (AMAX (idx ) - val_limit );
2032- }
2033-
20342008 if (trouble_count == 0 ) {
20352009 pline1 (nothing_happens );
20362010 return ;
2037- } else if (trouble_count > 1 ) { /* shuffle */
2038- int i , j , k ;
2039-
2040- for (i = trouble_count - 1 ; i > 0 ; i -- )
2041- if ((j = rn2 (i + 1 )) != i ) {
2042- k = trouble_list [j ];
2043- trouble_list [j ] = trouble_list [i ];
2044- trouble_list [i ] = k ;
2045- }
2046- }
2011+ } else if (trouble_count > 1 )
2012+ shuffle_int_array (trouble_list , trouble_count );
20472013
20482014 /*
20492015 * Chances for number of troubles to be fixed
@@ -2060,60 +2026,47 @@ struct obj *obj;
20602026 idx = trouble_list [val ];
20612027
20622028 switch (idx ) {
2063- case prop2trbl ( SICK ) :
2029+ case SICK :
20642030 make_sick (0L , (char * ) 0 , TRUE, SICK_ALL );
20652031 did_prop ++ ;
20662032 break ;
2067- case prop2trbl ( BLINDED ) :
2033+ case BLINDED :
20682034 make_blinded ((long ) u .ucreamed , TRUE);
20692035 did_prop ++ ;
20702036 break ;
2071- case prop2trbl ( HALLUC ) :
2037+ case HALLUC :
20722038 (void ) make_hallucinated (0L , TRUE, 0L );
20732039 did_prop ++ ;
20742040 break ;
2075- case prop2trbl ( VOMITING ) :
2041+ case VOMITING :
20762042 make_vomiting (0L , TRUE);
20772043 did_prop ++ ;
20782044 break ;
2079- case prop2trbl ( CONFUSION ) :
2045+ case CONFUSION :
20802046 make_confused (0L , TRUE);
20812047 did_prop ++ ;
20822048 break ;
2083- case prop2trbl ( STUNNED ) :
2049+ case STUNNED :
20842050 make_stunned (0L , TRUE);
20852051 did_prop ++ ;
20862052 break ;
2087- case prop2trbl ( DEAF ) :
2053+ case DEAF :
20882054 make_deaf (0L , TRUE);
20892055 did_prop ++ ;
20902056 break ;
20912057 default :
2092- if (idx >= 0 && idx < A_MAX ) {
2093- ABASE (idx ) += 1 ;
2094- did_attr ++ ;
2095- } else
2096- panic ("use_unicorn_horn: bad trouble? (%d)" , idx );
2058+ impossible ("use_unicorn_horn: bad trouble? (%d)" , idx );
20972059 break ;
20982060 }
20992061 }
21002062
2101- if (did_attr || did_prop )
2063+ if (did_prop )
21022064 g .context .botl = TRUE;
2103- if (did_attr )
2104- pline ("This makes you feel %s!" ,
2105- (did_prop + did_attr ) == (trouble_count + unfixable_trbl )
2106- ? "great"
2107- : "better" );
2108- else if (!did_prop )
2065+ else
21092066 pline ("Nothing seems to happen." );
21102067
21112068#undef PROP_COUNT
2112- #undef ATTR_COUNT
2113- #undef prop2trbl
2114- #undef attr2trbl
21152069#undef prop_trouble
2116- #undef attr_trouble
21172070#undef TimedTrouble
21182071}
21192072
@@ -3809,7 +3762,7 @@ doapply()
38093762 use_figurine (& obj );
38103763 break ;
38113764 case UNICORN_HORN :
3812- use_unicorn_horn (obj );
3765+ use_unicorn_horn (& obj );
38133766 break ;
38143767 case WOODEN_FLUTE :
38153768 case MAGIC_FLUTE :
0 commit comments