1 /* NetHack 3.7  botl.h  $NHDT-Date: 1596498528 2020/08/03 23:48:48 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.34 $ */
2 /* Copyright (c) Michael Allison, 2003                            */
3 /* NetHack may be freely redistributed.  See license for details. */
4 
5 #ifndef BOTL_H
6 #define BOTL_H
7 
8 /* MAXCO must hold longest uncompressed status line, and must be larger
9  * than COLNO
10  *
11  * longest practical second status line at the moment is
12 Astral Plane \GXXXXNNNN:123456 HP:1234(1234) Pw:1234(1234) AC:-127
13  Xp:30/123456789 T:123456  Stone Slime Strngl FoodPois TermIll
14  Satiated Overloaded Blind Deaf Stun Conf Hallu Lev Ride
15  * -- or about 185 characters.  '$' gets encoded even when it
16  * could be used as-is.  The first five status conditions are fatal
17  * so it's rare to have more than one at a time.
18  *
19  * When the full line is wider than the map, the basic status line
20  * formatting will move less important fields to the end, so if/when
21  * truncation is necessary, it will chop off the least significant
22  * information.
23  */
24 #if COLNO <= 160
25 #define MAXCO 200
26 #else
27 #define MAXCO (COLNO + 40)
28 #endif
29 
30 struct condmap {
31     const char *id;
32     unsigned long bitmask;
33 };
34 
35 enum statusfields {
36     BL_CHARACTERISTICS = -3, /* alias for BL_STR..BL_CH */
37     BL_RESET = -2,           /* Force everything to redisplay */
38     BL_FLUSH = -1,           /* Finished cycling through bot fields */
39     BL_TITLE = 0,
40     BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,  /* 1..6 */
41     BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX, /* 7..12 */
42     BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, /* 13..18 */
43     BL_HPMAX, BL_LEVELDESC, BL_EXP, BL_CONDITION, /* 19..22 */
44     MAXBLSTATS /* [23] */
45 };
46 
47 enum relationships { NO_LTEQGT = -1,
48                      EQ_VALUE, LT_VALUE, LE_VALUE,
49                      GE_VALUE, GT_VALUE, TXT_VALUE };
50 
51 enum blconditions {
52     bl_bareh,
53     bl_blind,
54     bl_busy,
55     bl_conf,
56     bl_deaf,
57     bl_elf_iron,
58     bl_fly,
59     bl_foodpois,
60     bl_glowhands,
61     bl_grab,
62     bl_hallu,
63     bl_held,
64     bl_icy,
65     bl_inlava,
66     bl_lev,
67     bl_parlyz,
68     bl_ride,
69     bl_sleeping,
70     bl_slime,
71     bl_slippery,
72     bl_stone,
73     bl_strngl,
74     bl_stun,
75     bl_submerged,
76     bl_termill,
77     bl_tethered,
78     bl_trapped,
79     bl_unconsc,
80     bl_woundedl,
81     bl_holding,
82     bl_wither,
83 
84     CONDITION_COUNT
85 };
86 
87 /* Boolean condition bits for the condition mask */
88 
89 /* clang-format off */
90 #define BL_MASK_BAREH        0x00000001L
91 #define BL_MASK_BLIND        0x00000002L
92 #define BL_MASK_BUSY         0x00000004L
93 #define BL_MASK_CONF         0x00000008L
94 #define BL_MASK_DEAF         0x00000010L
95 #define BL_MASK_ELF_IRON     0x00000020L
96 #define BL_MASK_FLY          0x00000040L
97 #define BL_MASK_FOODPOIS     0x00000080L
98 #define BL_MASK_GLOWHANDS    0x00000100L
99 #define BL_MASK_GRAB         0x00000200L
100 #define BL_MASK_HALLU        0x00000400L
101 #define BL_MASK_HELD         0x00000800L
102 #define BL_MASK_ICY          0x00001000L
103 #define BL_MASK_INLAVA       0x00002000L
104 #define BL_MASK_LEV          0x00004000L
105 #define BL_MASK_PARLYZ       0x00008000L
106 #define BL_MASK_RIDE         0x00010000L
107 #define BL_MASK_SLEEPING     0x00020000L
108 #define BL_MASK_SLIME        0x00040000L
109 #define BL_MASK_SLIPPERY     0x00080000L
110 #define BL_MASK_STONE        0x00100000L
111 #define BL_MASK_STRNGL       0x00200000L
112 #define BL_MASK_STUN         0x00400000L
113 #define BL_MASK_SUBMERGED    0x00800000L
114 #define BL_MASK_TERMILL      0x01000000L
115 #define BL_MASK_TETHERED     0x02000000L
116 #define BL_MASK_TRAPPED      0x04000000L
117 #define BL_MASK_UNCONSC      0x08000000L
118 #define BL_MASK_WOUNDEDL     0x10000000L
119 #define BL_MASK_HOLDING      0x20000000L
120 #define BL_MASK_WITHER       0x40000000L
121 #define BL_MASK_BITS            31 /* number of mask bits that can be set */
122 /* clang-format on */
123 
124 struct conditions_t {
125     int ranking;
126     long mask;
127     enum blconditions c;
128     const char *text[3];
129 };
130 extern const struct conditions_t conditions[CONDITION_COUNT];
131 
132 struct condtests_t {
133     enum blconditions c;
134     const char *useroption;
135     enum optchoice opt;
136     boolean enabled;
137     boolean choice;
138     boolean test;
139 };
140 
141 extern struct condtests_t condtests[CONDITION_COUNT];
142 extern int cond_idx[CONDITION_COUNT];
143 
144 #define BEFORE  0
145 #define NOW     1
146 
147 /*
148  * Possible additional conditions:
149  *  major:
150  *      grab   - grabbed by eel so about to be drowned ("wrapd"? damage type
151  *               is AD_WRAP but message is "<mon> swings itself around you")
152  *      digst  - swallowed and being digested
153  *      lava   - trapped sinking into lava
154  *  in_between: (potentially severe but don't necessarily lead to death;
155  *               explains to player why he isn't getting to take any turns)
156  *      unconc - unconscious
157  *      parlyz - (multi < 0 && (!strncmp(multi_reason, "paralyzed", 9)
158  *                              || !strncmp(multi_reason, "frozen", 6)))
159  *      asleep - (multi < 0 && !strncmp(multi_reason, "sleeping", 8))
160  *      busy   - other multi < 0
161  *  minor:
162  *      held   - grabbed by non-eel or by eel but not susceptible to drowning
163  *      englf  - engulfed or swallowed but not being digested (usually
164  *               obvious but the blank symbol set makes that uncertain)
165  *      vomit  - vomiting (causes confusion and stun late in countdown)
166  *      trap   - trapped in pit, bear trap, web, or floor (solidified lava)
167  *      teth   - tethered to buried iron ball
168  *      chain  - punished
169  *      slip   - slippery fingers
170  *      ice    - standing on ice (movement becomes uncertain)
171  *     [underwater - movement uncertain, vision truncated, equipment at risk]
172  *  other:
173  *     [hold      - poly'd into grabber and holding adjacent monster]
174  *      Stormbringer - wielded weapon poses risks
175  *      Cleaver   - wielded weapon risks unintended consequences
176  *      barehand  - not wielding any weapon nor wearing gloves
177  *      no-weapon - not wielding any weapon
178  *      bow/xbow/sling - wielding a missile launcher of specified type
179  *      pole      - wielding a polearm
180  *      pick      - wielding a pickaxe
181  *      junk      - wielding non-weapon, non-weptool
182  *      naked     - no armor
183  *      no-gloves - self-explanatory
184  *      no-cloak  - ditto
185  *     [no-{other armor slots?} - probably much too verbose]
186  *  conduct?
187  *      [maybe if third status line is added]
188  *
189  *  Can't add all of these and probably don't want to.  But maybe we
190  *  can add some of them and it's not as many as first appears:
191  *  lava/trap/teth are mutually exclusive;
192  *  digst/grab/englf/held/hold are also mutually exclusive;
193  *  Stormbringer/Cleaver/barehand/no-weapon/bow&c/pole/pick/junk too;
194  *  naked/no-{any armor slot} likewise.
195  */
196 
197 #define VIA_WINDOWPORT() \
198     ((windowprocs.wincap2 & (WC2_HILITE_STATUS | WC2_FLUSH_STATUS)) != 0)
199 
200 #define REASSESS_ONLY TRUE
201 
202 /* #ifdef STATUS_HILITES */
203 /* hilite status field behavior - coloridx values */
204 #define BL_HILITE_NONE -1    /* no hilite of this field */
205 #define BL_HILITE_INVERSE -2 /* inverse hilite */
206 #define BL_HILITE_BOLD -3    /* bold hilite */
207                              /* or any CLR_ index (0 - 15) */
208 #define BL_TH_NONE 0
209 #define BL_TH_VAL_PERCENTAGE 100 /* threshold is percentage */
210 #define BL_TH_VAL_ABSOLUTE 101   /* threshold is particular value */
211 #define BL_TH_UPDOWN 102         /* threshold is up or down change */
212 #define BL_TH_CONDITION 103      /* threshold is bitmask of conditions */
213 #define BL_TH_TEXTMATCH 104      /* threshold text value to match against */
214 #define BL_TH_ALWAYS_HILITE 105  /* highlight regardless of value */
215 
216 
217 #define HL_ATTCLR_DIM     CLR_MAX + 0
218 #define HL_ATTCLR_BLINK   CLR_MAX + 1
219 #define HL_ATTCLR_ULINE   CLR_MAX + 2
220 #define HL_ATTCLR_INVERSE CLR_MAX + 3
221 #define HL_ATTCLR_BOLD    CLR_MAX + 4
222 #define BL_ATTCLR_MAX     CLR_MAX + 5
223 
224 enum hlattribs { HL_UNDEF   = 0x00,
225                  HL_NONE    = 0x01,
226                  HL_BOLD    = 0x02,
227                  HL_INVERSE = 0x04,
228                  HL_ULINE   = 0x08,
229                  HL_BLINK   = 0x10,
230                  HL_DIM     = 0x20 };
231 
232 #define MAXVALWIDTH 80 /* actually less, but was using 80 to allocate title
233                        * and leveldesc then using QBUFSZ everywhere else   */
234 #ifdef STATUS_HILITES
235 struct hilite_s {
236     enum statusfields fld;
237     boolean set;
238     unsigned anytype;
239     anything value;
240     int behavior;
241     char textmatch[MAXVALWIDTH];
242     enum relationships rel;
243     int coloridx;
244     struct hilite_s *next;
245 };
246 #endif
247 
248 struct istat_s {
249     const char *fldname;
250     const char *fldfmt;
251     long time;  /* moves when this field hilite times out */
252     boolean chg; /* need to recalc time? */
253     boolean percent_matters;
254     short percent_value;
255     unsigned anytype;
256     anything a;
257     char *val;
258     int valwidth;
259     enum statusfields idxmax;
260     enum statusfields fld;
261 #ifdef STATUS_HILITES
262     struct hilite_s *hilite_rule; /* the entry, if any, in 'thresholds'
263                                    * list that currently applies        */
264     struct hilite_s *thresholds;
265 #endif
266 };
267 
268 extern const char *status_fieldnames[]; /* in botl.c */
269 
270 #endif /* BOTL_H */
271