1 /* File: defines.h */
2 
3 /* Purpose: server-side global constants and macro definitions */
4 
5 
6 /*
7  * Current version number of MAngband.
8  */
9 
10 #define SERVER_VERSION_MAJOR	1
11 #define SERVER_VERSION_MINOR	5
12 #define SERVER_VERSION_PATCH	3
13 
14 /*
15  * This value specifys the suffix to the version info sent to the metaserver.
16  *
17  * 0 - nothing
18  * 1 - "alpha"
19  * 2 - "beta"
20  * 3 - "development"
21  */
22 #define SERVER_VERSION_EXTRA	0
23 
24 
25 /*
26  * This value is a single 16-bit number holding the version info
27  */
28 
29 #define SERVER_VERSION ( \
30   SERVER_VERSION_MAJOR << 12 | SERVER_VERSION_MINOR << 8 \
31   | SERVER_VERSION_PATCH << 4 | SERVER_VERSION_EXTRA)
32 
33 
34 /*
35  * The maximum number of player ID's
36  */
37 #define MAX_ID 4096
38 
39 
40 /*
41  * This is very important...
42  *
43  * This is the number of "frames" to produce per second.  It determines
44  * the speed of the game.
45  */
46 #define FPS 12
47 
48 /* maximum respawn time for uniques.... from japanese patch */
49 #define COME_BACK_TIME_MAX 600
50 
51 /*
52  * A "stack" of items is limited to less than 100 items (hard-coded).
53  */
54 #define MAX_STACK_SIZE			100
55 /*
56  * Total number of owners per store (see "store.c", etc)
57  */
58 #define MAX_OWNERS	4
59 
60 /*
61  * Maximum number of player "race" types (see "table.c", etc)
62  */
63 #define MAX_RACES           11
64 
65 /*
66  * Maximum number of player "class" types (see "table.c", etc)
67  */
68 #define MAX_CLASS            6
69 
70 /*
71  * Maximum number of player "sex" types (see "table.c", etc)
72  */
73 #define MAX_SEXES            2
74 
75 /*
76  * Total number of stores (see "store.c", etc)
77  */
78 #define MAX_STORES	9
79 
80 /*
81  * Maximum number of parties to allow.  If, while trying to create a new
82  * party, you get a "No empty party slot" or somesuch message, increase
83  * this number.  However, you should NEVER decrease this number after a
84  * server has been run, or all sorts of bad things could happen.
85  */
86 #define MAX_PARTIES	256
87 
88 /*
89  * Maximum number of houses available.
90  */
91 #define MAX_HOUSES	1024
92 
93 /*
94  * Total number of arenas
95  */
96 #define MAX_ARENAS	10
97 
98 /*
99  * Number of entries in the player name hash table.
100  * This must be a power of 2!
101  */
102 #define NUM_HASH_ENTRIES	256
103 
104 
105 /* Maximum number of items in ITEMLIST window/command */
106 #define MAX_ITEMLIST 256
107 
108 /*
109  * Indexes of the various "stats" (hard-coded by savefiles, etc).
110  */
111 #define A_STR	0
112 #define A_INT	1
113 #define A_WIS	2
114 #define A_DEX	3
115 #define A_CON	4
116 #define A_CHR	5
117 
118 /*
119  * Total number of stats.
120  */
121 #define A_MAX	6
122 
123 
124 /*
125  * Player race constants (hard-coded by save-files, arrays, etc)
126  */
127 #define RACE_HUMAN		0
128 #define RACE_HALF_ELF	1
129 #define RACE_ELF		2
130 #define RACE_HOBBIT		3
131 #define RACE_GNOME		4
132 #define RACE_DWARF		5
133 #define RACE_HALF_ORC	6
134 #define RACE_HALF_TROLL	7
135 #define RACE_DUNADAN	8
136 #define RACE_HIGH_ELF	9
137 #define RACE_KOBOLD		10
138 
139 /*
140  * Player class constants (hard-coded by save-files, arrays, etc)
141  */
142 #define CLASS_WARRIOR	0
143 #define CLASS_MAGE		1
144 #define CLASS_PRIEST	2
145 #define CLASS_ROGUE		3
146 #define CLASS_RANGER	4
147 #define CLASS_PALADIN	5
148 
149 /*
150  * Misc constants
151  */
152 #define SERVER_SAVE	10		/* Minutes between server saves */
153 #define TOWN_DAWN		50000	/* Number of turns from dawn to dawn XXX */
154 #define GROW_TREE	5000		/* How often to grow a new tree in town */
155 #define GROW_CROPS	5000		/* How often to grow a bunch of new vegetables in wilderness */
156 #define BREAK_GLYPH		550		/* Rune of protection resistance */
157 #define BTH_PLUS_ADJ    3       /* Adjust BTH per plus-to-hit */
158 #define MON_MULT_ADJ	8		/* High value slows multiplication */
159 #define MON_SUMMON_ADJ	2		/* Adjust level of summoned creatures */
160 #define MON_DRAIN_LIFE	2		/* Percent of player exp drained per hit */
161 #define USE_DEVICE      3		/* x> Harder devices x< Easier devices     */
162 
163 /* Resistance panel */
164 #define MAX_OBJFLAGS_ROWS 13
165 #define MAX_OBJFLAGS_COLS 39
166 
167 /*
168  * There is a 1/20 (5%) chance of inflating the requested object_level
169  * during the creation of an object (see "get_obj_num()" in "object.c").
170  * Lower values yield better objects more often.
171  */
172 #define GREAT_OBJ	20
173 
174 /*
175  * There is a 1/50 (2%) chance of inflating the requested monster_level
176  * during the creation of a monsters (see "get_mon_num()" in "monster.c").
177  * Lower values yield harder monsters more often.
178  */
179 #define NASTY_MON	50		/* 1/chance of inflated monster level */
180 
181 
182 
183 /*
184  * Refueling constants
185  */
186 #define FUEL_TORCH	5000	/* Maximum amount of fuel in a torch */
187 #define FUEL_LAMP	15000   /* Maximum amount of fuel in a lantern */
188 
189 
190 /*
191  * More maximum values
192  */
193 #define MAX_SIGHT	20	/* Maximum view distance */
194 #define MAX_RANGE	18	/* Maximum range (spells, etc) */
195 
196 /*
197  * Maximum number of picked up/stolen objects a monster can carry
198  */
199 #define MAX_MONSTER_BAG 25 /* Undef to unlimit */
200 
201 /*
202  * There is a 1/160 chance per round of creating a new monster
203  */
204 #define MAX_M_ALLOC_CHANCE	160
205 
206 /*
207  * Normal levels get at least 14 monsters
208  */
209 #define MIN_M_ALLOC_LEVEL	14
210 
211 /*
212  * The town starts out with 4 residents during the day
213  */
214 #define MIN_M_ALLOC_TD		4
215 
216 /*
217  * The town starts out with 8 residents during the night
218  */
219 #define MIN_M_ALLOC_TN		8
220 
221 
222 /* Macros for determing if it is night or day */
223 
224 #define		IS_DAY	 ((turn.turn % (10L * TOWN_DAWN)) <= (10L * TOWN_DAWN / 2))
225 #define		IS_NIGHT ((turn.turn % (10L * TOWN_DAWN)) > (10L * TOWN_DAWN / 2))
226 
227 
228 /*
229  * A monster can only "multiply" (reproduce) if there are fewer than 100
230  * monsters on the level capable of such spontaneous reproduction.  This
231  * is a hack which prevents the "m_list[]" array from exploding due to
232  * reproducing monsters.  Messy, but necessary.
233  */
234 #define MAX_REPRO	100
235 
236 
237 
238 
239 /*
240  * Player "food" crucial values
241  */
242 #define PY_FOOD_MAX		15000	/* Food value (Bloated) */
243 #define PY_FOOD_FULL	10000	/* Food value (Normal) */
244 #define PY_FOOD_ALERT	2000	/* Food value (Hungry) */
245 #define PY_FOOD_WEAK	1000	/* Food value (Weak) */
246 #define PY_FOOD_FAINT	500		/* Food value (Fainting) */
247 #define PY_FOOD_STARVE	100		/* Food value (Starving) */
248 
249 /*
250  * Player regeneration constants
251  */
252 #define PY_REGEN_NORMAL		197		/* Regen factor*2^16 when full */
253 #define PY_REGEN_WEAK		98		/* Regen factor*2^16 when weak */
254 #define PY_REGEN_FAINT		33		/* Regen factor*2^16 when fainting */
255 #define PY_REGEN_HPBASE		1442	/* Min amount hp regen*2^16 */
256 #define PY_REGEN_MNBASE		524		/* Min amount mana regen*2^16 */
257 
258 
259 /*
260  * Time bubble scale factors in percentage terms
261  */
262 #define MAX_TIME_SCALE	1000
263 #define MIN_TIME_SCALE	10
264 #define RUNNING_FACTOR	500		/* Increase time by this percentage when running */
265 #define NORMAL_TIME		100		/* 100% */
266 /*
267  * When player is low on HP, divide time factor by CONSTANT_TIME_FACTOR.
268  * To enable varying health-based factor (e.g. 50% health = 50% time slowdown)
269  * undefine CONSTANT_TIME_FACTOR.
270  */
271 #define CONSTANT_TIME_FACTOR	5	/* N times slower */
272 
273 
274 /*
275  * Maximum number of options and option groups
276  */
277 #define	OPT_MAX             45
278 #define	MAX_OPTION_GROUPS   4
279 
280 /*
281  * Available Options
282  *
283  * It is very important that all options stay together
284  * without any gaps, OPT_MAX must not exceed them too.
285  * Order, on the other hand, is not important.
286  *
287  *  *** WRONG ***			*** CORRECT ***
288  * OPT_MAX       64			OPT_MAX       2
289  * OPT_NO_GHOST  5          OPT_NO_GHOST  0
290  * OPT_SUN_LIGHT 9          OPT_SUN_LIGHT 1
291  */
292 #define OPT_NO_GHOST    		0
293 #define OPT_DEPTH_IN_FEET   	1
294 #define OPT_DUNGEON_ALIGN   	2
295 #define OPT_AVOID_OTHER 		3
296 #define OPT_USE_COLOR   		4
297 #define OPT_AUTO_SCUM       	5
298 #define OPT_EXPAND_LOOK 		6
299 #define OPT_SHOW_DETAILS    	7
300 #define OPT_CARRY_QUERY_FLAG	8
301 #define OPT_ALWAYS_PICKUP   	9
302 #define OPT_USE_OLD_TARGET  	10
303 #define OPT_STACK_FORCE_NOTES	11
304 #define OPT_STACK_FORCE_COSTS	12
305 #define OPT_STACK_ALLOW_ITEMS	13
306 #define OPT_STACK_ALLOW_WANDS	14
307 #define OPT_FIND_IGNORE_STAIRS	15
308 #define OPT_FIND_IGNORE_DOORS	16
309 #define OPT_FIND_CUT        	17
310 #define OPT_FIND_EXAMINE    	18
311 #define OPT_DISTURB_MOVE    	19
312 #define OPT_DISTURB_NEAR    	20
313 #define OPT_DISTURB_PANEL   	21
314 #define OPT_DISTURB_STATE   	22
315 #define OPT_DISTURB_MINOR   	23
316 #define OPT_DISTURB_OTHER   	24
317 #define OPT_VIEW_PERMA_GRIDS	25
318 #define OPT_VIEW_TORCH_GRIDS	26
319 #define OPT_VIEW_REDUCE_LITE	27
320 #define OPT_VIEW_REDUCE_VIEW	28
321 #define OPT_VIEW_YELLOW_LITE	29
322 #define OPT_VIEW_BRIGHT_LITE	30
323 #define OPT_VIEW_GRANITE_LITE	31
324 #define OPT_VIEW_SPECIAL_LITE	32
325 #define OPT_VIEW_ORANGE_LITE	33
326 #define OPT_EASY_ALTER			34
327 #define OPT_ALERT_HITPOINT		35
328 #define OPT_HILITE_LEADER   	36
329 #define OPT_PAUSE_AFTER_DETECT 	37
330 #define OPT_DISTURB_LOOK    	38
331 #define OPT_UNSETH_BONUS    	39
332 #define OPT_EXPAND_INSPECT	40
333 #define OPT_ENERGY_BUILDUP	41
334 #define OPT_MONSTER_RECOIL	42
335 #define OPT_BUMP_OPEN   	43
336 #define OPT_PICKUP_INVEN	44
337 #define option_p(A,B) (A->options[OPT_ ## B])
338 
339 
340 /*
341  * Buffers for ".txt" text files
342  */
343 #define MAX_TEXTFILES 2
344 #define TEXTFILE__WID 80
345 #define TEXTFILE__HGT 23
346 #define TEXTFILE_MOTD 0
347 #define TEXTFILE_TOMB 1
348 
349 
350 /*
351  * indicators / print-fields defines
352  */
353 #define MAX_INDICATORS 64
354 
355 /* Those IDs must match the order of indicators[] array from tables.c */
356 /* Player compact */
357 #define IN_RACE     	0
358 #define IN_CLASS    	1
359 #define IN_TITLE    	2
360 #define IN_LEVEL    	3
361 #define IN_EXP      	4
362 #define IN_GOLD     	5
363 #define IN_STAT0    	6
364 #define IN_STAT1    	7
365 #define IN_STAT2    	8
366 #define IN_STAT3    	9
367 #define IN_STAT4    	10
368 #define IN_STAT5    	11
369 #define IN_ARMOR    	12
370 #define IN_HP       	13
371 #define IN_SP       	14
372 #define IN_MON_HEALTH	15
373 #define IN_CUT      	16
374 /* Status line */
375 #define IN_FOOD     	17
376 #define IN_BLIND    	18
377 #define IN_STUN     	19
378 #define IN_CONFUSED 	20
379 #define IN_AFRAID   	21
380 #define IN_POISONED 	22
381 #define IN_STATE    	23
382 #define IN_SPEED    	24
383 #define IN_STUDY    	25
384 #define IN_DEPTH    	26
385 #define IN_OPPOSE   	27
386 /* Charsheet */
387 #define IN_VARIOUS    	28
388 #define IN_SKILLS    	29
389 #define IN_SKILLS2    	30
390 #define IN_PLUSSES    	31
391 #define IN_HISTORY0 	32
392 #define IN_HISTORY1 	33
393 #define IN_HISTORY2 	34
394 #define IN_HISTORY3 	35
395 #define IN_NAME     	36
396 #define IN_GENDER   	37
397 
398 /*** Screen Locations ***/
399 
400 #define ROW_RACE    	1
401 #define COL_RACE    	0	/* <race name> */
402 
403 #define ROW_CLASS   	2
404 #define COL_CLASS   	0	/* <class name> */
405 
406 #define ROW_TITLE   	3
407 #define COL_TITLE   	0	/* <title> or <mode> */
408 
409 #define ROW_LEVEL   	4
410 #define COL_LEVEL   	0	/* "LEVEL xxxxxx" */
411 
412 #define ROW_EXP     	5
413 #define COL_EXP     	0	/* "EXP xxxxxxxx" */
414 
415 #define ROW_GOLD    	6
416 #define COL_GOLD    	0	/* "AU xxxxxxxxx" */
417 
418 #define ROW_EQUIPPY 	14
419 #define COL_EQUIPPY 	0	/* equippy chars */
420 
421 #define ROW_LAG     	7
422 #define COL_LAG     	0	/* "LAG xxxxxxxx" */
423 
424 #define ROW_STAT    	8
425 #define COL_STAT    	0	/* "xxx   xxxxxx" */
426 /* takes up 6 rows... */
427 
428 #define ROW_AC      	15
429 #define COL_AC      	0	/* "Cur AC xxxxx" */
430 
431 #define ROW_MAXHP   	16
432 #define COL_MAXHP   	0	/* "Max HP xxxxx" */
433 
434 #define ROW_CURHP   	17
435 #define COL_CURHP   	0	/* "Cur HP xxxxx" */
436 
437 #define ROW_MAXSP   	18
438 #define COL_MAXSP   	0	/* "Max SP xxxxx" */
439 
440 #define ROW_CURSP   	19
441 #define COL_CURSP   	0	/* "Cur SP xxxxx" */
442 
443 #define ROW_INFO    	20
444 #define COL_INFO    	0	/* "xxxxxxxxxxxx" */
445 
446 #define ROW_CUT     	21
447 #define COL_CUT     	0	/* <cut> */
448 
449 #define ROW_STUN    	22
450 #define COL_STUN    	0	/* <stun> */
451 
452 #define ROW_HUNGRY  	-1
453 #define COL_HUNGRY  	0	/* "Weak" / "Hungry" / "Full" / "Gorged" */
454 
455 #define ROW_BLIND   	-1
456 #define COL_BLIND   	7	/* "Blind" */
457 
458 #define ROW_CONFUSED	-1
459 #define COL_CONFUSED	13	/* "Confused" */
460 
461 #define ROW_AFRAID  	-1
462 #define COL_AFRAID  	22	/* "Afraid" */
463 
464 #define ROW_POISONED	-1
465 #define COL_POISONED	29	/* "Poisoned" */
466 
467 #define ROW_STATE   	-1
468 #define COL_STATE   	38	/* <state> */
469 
470 #define ROW_SPEED   	-1
471 #define COL_SPEED   	49	/* "Slow (-NN)" or "Fast (+NN)" */
472 
473 #define ROW_STUDY   	-1
474 #define COL_STUDY   	64	/* "Study" */
475 
476 #define ROW_DEPTH   	-1
477 #define COL_DEPTH   	70	/* "Lev NNN" / "NNNN ft" */
478 
479 #define ROW_OPPOSE_ELEMENTS	-1
480 #define COL_OPPOSE_ELEMENTS	80	/* "Acid Elec Fire Cold Pois" */
481 
482 
483 /*
484  * item_tester_hook defines
485  */
486 #define ITH_WEAR        	1
487 #define ITH_WEAPON      	2
488 #define ITH_ARMOR       	3
489 #define ITH_AMMO        	4
490 #define ITH_RECHARGE    	5
491 #define ITH_ACTIVATE    	6
492 #define ITH_REFILL      	7
493 #define item_test(A) (TV_MAX + (ITH_ ## A))
494 #define ITEM_ANY        	0
495 
496 /*
497  * item_tester_flag defines
498  */
499 #define ITF_WEAR	0x01 /* Can wear/wield item */
500 #define ITF_ACT 	0x02 /* Can activate item */
501 #define ITF_FUEL 	0x04 /* Can be used as fuel */
502 #define ITF_FLAG_0 	0x08
503 
504 #define ITF_FLAG_1 	ITEM_ASK_AIM  /* Reserved */
505 #define ITF_FLAG_2 	ITEM_ASK_ITEM /* Reserved */
506 #define ITF_FLAG_3 	0x40 /* Variant-specific */
507 #define ITF_FLAG_4 	0x80 /* Variant-specific */
508 
509 /*
510  * Chat Channels defines
511  */
512 /* channel modes */
513 #define	CM_KEYLOCK	0x01 /* +k More similar to IRC's +A */
514 #define	CM_SECRET	0x02 /* +s */
515 #define	CM_MODERATE 0x04 /* +m */
516 #define	CM_SERVICE 	0x08 /* +! service channel */
517 #define	CM_PLOG 	0x10 /* +p log to plog */
518 /* user-channel modes */
519 #define	UCM_EAR  	0x01
520 #define	UCM_VOICE	0x02
521 #define	UCM_OPER 	0x04
522 #define	UCM_BAN  	0x08
523 
524 #define UCM_LEAVE 	(UCM_EAR | UCM_VOICE | UCM_OPER)
525 #define on_channel(P,I) ((P)->on_channel[(I)] & UCM_EAR)
526 
527 /* can_talk(p_ptr, channel_index) test:
528  * Line 1. Present on channel
529  * Line 2. Not banned
530  * Line 3. Not moderated
531  * Line 4. Moderated, BUT
532  * Line 5.  user has Voice or Op */
533 #define can_talk(P,I) \
534 	(on_channel((P),(I)) && \
535 	!((P)->on_channel[(I)] & UCM_BAN) && \
536 	(!(channels[(I)].mode & CM_MODERATE) || ( \
537 	(channels[(I)].mode & CM_MODERATE) && \
538 		( (P)->on_channel[(I)] & UCM_VOICE || (P)->on_channel[(I)] & UCM_OPER ) \
539 	)))
540 
541 #define clog(C,M) if (chan_ ## C) msg_channel(chan_ ## C, (M))
542 #define audit(M) clog(audit, (M))
543 #define debug(M) clog(debug, (M))
544 #define cheat(M) clog(cheat, (M))
545 
546 /* Transitional networking helpers */
547 #define ConnPlayers(IND) players->list[IND]->data2
548 #define NumPlayers p_max
549 #define Players p_list
550 
551 /*
552  * Stream-related
553  */
554 #define STREAM_DUNGEON_ASCII	0
555 #define STREAM_DUNGEON_GRAF1	1
556 #define STREAM_DUNGEON_GRAF2	2
557 #define STREAM_MINIMAP_ASCII	3
558 #define STREAM_MINIMAP_GRAF 	4
559 #define STREAM_BGMAP_ASCII  	5
560 #define STREAM_BGMAP_GRAF   	6
561 #define STREAM_SPECIAL_MIXED 	7
562 #define STREAM_SPECIAL_TEXT  	8
563 #define STREAM_MONSTER_TEXT  	9
564 #define STREAM_MONLIST_TEXT  	10
565 #define STREAM_ITEMLIST_TEXT	11
566 #define STREAM_FILE_TEXT    	12
567 
568 #define Stream_line(I,S,L) stream_line_as(Players[I],S,L,L)
569 #define Stream_line_p(P,S,L) stream_line_as(P,S,L,L)
570 
571 #define DUNGEON_STREAM_p(P) ((P)->use_graphics > GRAPHICS_PLAIN ? STREAM_DUNGEON_GRAF2 : ((P)->use_graphics ? STREAM_DUNGEON_GRAF1 : STREAM_DUNGEON_ASCII ))
572 #define MINIMAP_STREAM_p(P) ((P)->use_graphics ? STREAM_MINIMAP_GRAF : STREAM_MINIMAP_ASCII)
573 #define BGMAP_STREAM_p(P) ((P)->use_graphics ? STREAM_BGMAP_GRAF : STREAM_BGMAP_ASCII)
574 
575 #define Send_char(I,X,Y,A,C) stream_char_raw(Players[I],STREAM_SPECIAL_MIXED,Y,X,A,C,A,C)
576 #define Send_char_p(P,X,Y,A,C) stream_char_raw(P,STREAM_SPECIAL_MIXED,Y,X,A,C,A,C)
577 #define Send_tile(P,X,Y,A,C,TA,TC) stream_char_raw((P),DUNGEON_STREAM_p((P)),Y,X,A,C,TA,TC)
578 #define Stream_tile(I,P,Y,X) stream_char(Players[I],DUNGEON_STREAM_p(P),Y,X);
579 #define Stream_tile_p(P,Y,X) stream_char(P,DUNGEON_STREAM_p(P),Y,X);
580 
581 /*
582  * The types of special file perusal.
583  */
584 #define SPECIAL_FILE_NONE	0
585 #define SPECIAL_FILE_OTHER	1
586 #define SPECIAL_FILE_ARTIFACT	2
587 #define SPECIAL_FILE_PLAYER	3
588 #define SPECIAL_FILE_UNIQUE	4
589 #define SPECIAL_FILE_SCORES	5
590 #define SPECIAL_FILE_HELP	6
591 #define SPECIAL_FILE_KNOWLEDGE	7
592 #define SPECIAL_FILE_HOUSES	8
593 #define SPECIAL_FILE_OBJECT	9
594 #define SPECIAL_FILE_KILL	10
595 #define SPECIAL_FILE_HISTORY	11
596 #define SPECIAL_FILE_SELF	12
597 #define SPECIAL_FILE_MASTER	13
598 #define SPECIAL_FILE_INPUT	14
599 
600 
601 /*
602  * Miscelanious hacks
603  */
604 /* Hack -- see if player is playing the game already */
605 #define IS_PLAYING(P) ((P)->state == PLAYER_PLAYING ? TRUE : FALSE)
606 /* Hack -- check if object is owned by player */
607 #define obj_own_p(P,O) ((!(O)->owner_id || (P)->id == (O)->owner_id))
608 /* Hack -- shorthand alias for "check_prevent_inscription" */
609 #define CPI(P,M) (P)->prevents[(byte)(M)]
610 /* Hack -- shorthand alias for "check_guard_inscription" */
611 #define CGI(O,M) check_guard_inscription( (O)->note, (M) )
612 /* Hack -- overloaded guard-inscriptions */
613 #define protected_p(P,O,M) (!is_dm_p((P)) && !obj_own_p((P), (O)) && CGI((O), (M)))
614 /* Hack -- check guard inscription and abort (chunk of code) */
615 #define __trap(P,X) if ((X)) { msg_print((P), "The item's inscription prevents it."); return; }
616 /* Hack -- ensure a variable fits into ddx/ddy array bounds */
617 #define VALID_DIR(D) ((D) > 0 && (D) < 10)
618 
619 /*
620  * Per-player artifact states
621  */
622 #define ARTS_NOT_FOUND	0
623 #define ARTS_FOUND  	1
624 #define ARTS_ABANDONED	2
625 #define ARTS_SOLD   	3
626 
627 #define set_artifact_p(P, A, I) if ((P)->a_info[(A)] < (I)) (P)->a_info[(A)] = (I)
628 
629 /*
630  * Monster sorting flags
631  */
632 #define SORT_EXP	0x0001
633 #define SORT_LEVEL	0x0002
634 #define SORT_PKILL	0x0004
635 #define SORT_TKILL	0x0008
636 #define SORT_EASY	0x000F
637 #define SORT_RARITY	0x0010
638 #define SORT_RICH	0x0020
639 #define SORT_UNIQUE	0x0040
640 #define SORT_QUEST	0x0080
641 
642 
643 /*
644  * MAngband-specific miscellaneous hacks
645  */
646 #define PURSE_MULTIPLIER 5 /* For store owners */
647 #define RIFT_RESIST_TELEPORT 127 /* For monsters */
648 #define PROJECTED_CHANCE_RATIO 50 /* (1.5) For players */
649 
650 /*
651  * Dungeon master flags
652  */
653 #define DM_IS_MASTER    	0x00000001
654 #define DM_SECRET_PRESENCE	0x00000002	/* cfg_secret_dungeon_master helper */
655 #define DM_CAN_MUTATE_SELF	0x00000004	/* This option allows change of the DM_ options */
656 #define DM_CAN_ASSIGN   	0x00000008
657 #define DM___MENU       	0x000000F0	/* Dungeon Master Menu: (shortcut to set all) */
658 #define DM_CAN_BUILD    	0x00000010  /*  building menu */
659 #define DM_LEVEL_CONTROL	0x00000020	/*  static/unstatic level */
660 #define DM_CAN_SUMMON   	0x00000040	/*  summon monsters */
661 #define DM_CAN_GENERATE 	0x00000080	/*  generate vaults / items */
662 #define DM_MONSTER_FRIEND	0x00000100
663 #define DM_INVULNERABLE 	0x00000200
664 #define DM_GHOST_HANDS  	0x00000400	/* Can interact with world (like open/close doors) even as a ghost */
665 #define DM_GHOST_BODY   	0x00000800	/* Can carry/wield items even as a ghost */
666 #define DM_NEVER_DISTURB	0x00001000
667 #define DM_SEE_LEVEL    	0x00002000	/* See all level */
668 #define DM_SEE_MONSTERS 	0x00004000	/* Free ESP + Monster spoilers */
669 #define DM_SEE_PLAYERS  	0x00008000	/* Full Info + "Player spoilers" */
670 #define DM_HOUSE_CONTROL	0x00010000	/* Can reset houses */
671 #define DM_KEEP_LITE    	0x00020000	/* Lite radius never changes */
672 #define DM_OBJECT_CONTROL	0x00040000	/* Can reset objects */
673 #define DM_ARTIFACT_CONTROL	0x00080000	/* Can reset artifacts */
674 #define DM_MISC_XXX1    	0x10000000
675 #define DM_MISC_XXX2    	0x20000000	/* DM_MISC_XXX -- For grouping some minor features together */
676 #define DM_MISC_XXX3    	0x40000000
677 #define DM_MISC_XXX4    	0x80000000
678 
679 #define is_dm(IND) \
680 	((Players[IND]->dm_flags & DM_IS_MASTER) ? TRUE : FALSE)
681 
682 #define is_dm_p(P) \
683 	(((P)->dm_flags & DM_IS_MASTER) ? TRUE : FALSE)
684 
685 #define dm_flag(IND,F) \
686 	((Players[(IND)]->dm_flags & & DM_ ## F) ? TRUE : FALSE)
687 
688 #define dm_flag_p(P,F) \
689 	(((P)->dm_flags & DM_ ## F) ? TRUE : FALSE)
690 
691 #define c_put_p(P,A,C,Y,X) { (P)->info[(Y)][(X)].a = (A); (P)->info[(Y)][(X)].c = (C); }
692 #define c_put(IND,A,C,Y,X) c_put_p(Players[IND],A,C,Y,X)
693 
694 /*
695  * Maximum number of "normal" pack slots, and the index of the "overflow"
696  * slot, which can hold an item, but only temporarily, since it causes the
697  * pack to "overflow", dropping the "last" item onto the ground.  Since this
698  * value is used as an actual slot, it must be less than "INVEN_WIELD" (below).
699  * Note that "INVEN_PACK" is probably hard-coded by its use in savefiles, and
700  * by the fact that the screen can only show 23 items plus a one-line prompt.
701  */
702 #define INVEN_PACK		23
703 
704 /*
705  * Indexes used for various "equipment" slots (hard-coded by savefiles, etc).
706  */
707 #define INVEN_WIELD		24
708 #define INVEN_BOW       25
709 #define INVEN_LEFT      26
710 #define INVEN_RIGHT     27
711 #define INVEN_NECK      28
712 #define INVEN_LITE      29
713 #define INVEN_BODY      30
714 #define INVEN_OUTER     31
715 #define INVEN_ARM       32
716 #define INVEN_HEAD      33
717 #define INVEN_HANDS     34
718 #define INVEN_FEET      35
719 
720 /*
721  * Total number of inventory slots (hard-coded).
722  */
723 #define INVEN_TOTAL	36
724 
725 /*
726  * This defines our way to index floor items
727  * during client-server communications.
728  */
729 #define FLOOR_INDEX     (-11)
730 #define FLOOR_NEGATIVE  TRUE
731 #define FLOOR_TOTAL     1
732 
733 /*
734  * Maximum number of objects allowed in a single dungeon grid.
735  *
736  * The main-screen has a minimum size of 24 rows, so we can always
737  * display 23 objects + 1 header line.
738  * MAngband-specific: we do not support floor piles, so this is set to "1",
739  * same as FLOOR_TOTOAL.
740  */
741 #define MAX_FLOOR_STACK			1/*23*/
742 
743 
744 /* Object origin kinds */
745 /* NOTE: do not change this unless you intend to break savefiles */
746 enum {
747 	ORIGIN_NONE = 0,
748 	ORIGIN_FLOOR,			/* found on the dungeon floor */
749 	ORIGIN_DROP,			/* normal monster drops */
750 	ORIGIN_CHEST,			/* from chest (depth should be copied) */
751 	ORIGIN_DROP_SPECIAL,		/* from monsters in special rooms */
752 	ORIGIN_DROP_PIT,		/* from monsters in pits/nests */
753 	ORIGIN_DROP_VAULT,		/* from monsters in vaults */
754 	ORIGIN_SPECIAL,			/* on the floor of a special room */
755 	ORIGIN_PIT,			/* on the floor of a pit/nest */
756 	ORIGIN_VAULT,			/* on the floor of a vault */
757 	ORIGIN_LABYRINTH,		/* on the floor of a labyrinth */
758 	ORIGIN_CAVERN,			/* on the floor of a cavern */
759 	ORIGIN_RUBBLE,			/* found under rubble */
760 	ORIGIN_MIXED,			/* stack with mixed origins */
761 	ORIGIN_STATS,			/* ^ only the above are considered by main-stats */
762 	ORIGIN_ACQUIRE,			/* called forth by scroll */
763 	ORIGIN_DROP_BREED,		/* from breeders */
764 	ORIGIN_DROP_SUMMON,		/* from combat summons */
765 	ORIGIN_STORE,			/* something you bought */
766 	ORIGIN_STOLEN,			/* stolen by monster (used only for gold) */
767 	ORIGIN_BIRTH,			/* objects created at character birth */
768 	ORIGIN_DROP_UNKNOWN,		/* drops from unseen foes */
769 	ORIGIN_CHEAT,			/* created by wizard mode */
770 	ORIGIN_DROP_POLY,		/* from polymorphees */
771 	ORIGIN_DROP_WIZARD,		/* from wizard mode summons */
772 	ORIGIN_WILD_DWELLING,		/* from wilderness dwellings */
773 
774 	ORIGIN_MAX
775 };
776 
777 #define ORIGIN_SIZE FLAG_SIZE(ORIGIN_MAX)
778 #define ORIGIN_BYTES 4 /* savefile bytes - room for 32 origin types */
779 
780 
781 /*
782  * Legal restrictions for "summon_specific()"
783  */
784 #define SUMMON_ANIMAL		1
785 #define SUMMON_SPIDER		2
786 #define SUMMON_HOUND		3
787 #define SUMMON_HYDRA		4
788 #define SUMMON_ANGEL		5
789 #define SUMMON_DEMON		6
790 #define SUMMON_UNDEAD		7
791 #define SUMMON_DRAGON		8
792 #define SUMMON_HI_UNDEAD	9
793 #define SUMMON_HI_DRAGON	10
794 #define SUMMON_HI_DEMON		11
795 #define SUMMON_WRAITH		12
796 #define SUMMON_UNIQUE		13
797 #define SUMMON_KIN			14
798 #define SUMMON_ORC			15
799 
800 
801 
802 /*** Terrain Feature Indexes (see "lib/edit/f_info.txt") ***/
803 
804 /* Nothing */
805 #define FEAT_NONE		0x00
806 
807 /* Various */
808 #define FEAT_FLOOR		0x01
809 #define FEAT_INVIS		0x02
810 #define FEAT_GLYPH		0x03
811 #define FEAT_OPEN		0x04
812 #define FEAT_BROKEN		0x05
813 #define FEAT_LESS		0x06
814 #define FEAT_MORE		0x07
815 
816 /* Shops */
817 #define FEAT_SHOP_HEAD	0x08
818 #define FEAT_SHOP_TAIL	0x0F
819 
820 /* Traps */
821 #define FEAT_TRAP_HEAD	0x10
822 #define FEAT_TRAP_TAIL	0x1F
823 
824 /* Doors */
825 #define FEAT_DOOR_HEAD	0x20
826 #define FEAT_DOOR_TAIL	0x2F
827 
828 /* Extra */
829 #define FEAT_SECRET	0x30
830 #define FEAT_RUBBLE	0x31
831 
832 /* Seams */
833 #define FEAT_MAGMA	0x32
834 #define FEAT_QUARTZ	0x33
835 #define FEAT_MAGMA_H	0x34
836 #define FEAT_QUARTZ_H	0x35
837 #define FEAT_MAGMA_K	0x36
838 #define FEAT_QUARTZ_K	0x37
839 
840 /* Walls */
841 #define FEAT_WALL_EXTRA	0x38
842 #define FEAT_WALL_INNER	0x39
843 #define FEAT_WALL_OUTER	0x3A
844 #define FEAT_WALL_SOLID	0x3B
845 #define FEAT_PERM_EXTRA	0x3C
846 #define FEAT_PERM_INNER	0x3D
847 #define FEAT_PERM_OUTER	0x3E
848 #define FEAT_PERM_SOLID	0x3F
849 
850 /* adding various wilderness features here.
851 feat_perm is used for an "invisible" outside wall
852 that keeps many algorithms happy.
853 -APD- */
854 #define FEAT_DRAWBRIDGE	0x50
855 #define FEAT_LOGS			0x60
856 #define FEAT_PERM_CLEAR	0x70
857 #define FEAT_PVP_ARENA 	0x5F
858 
859 /* Trees */
860 #define FEAT_TREE			0x61
861 #define FEAT_EVIL_TREE  0x62
862 
863 /* Wilds */
864 #define FEAT_DIRT				0x40
865 #define FEAT_GRASS			0x41
866 #define FEAT_CROP				0x42
867 #define FEAT_LOOSE_DIRT		0x44
868 #define FEAT_WATER			0x4C
869 #define FEAT_MUD				0x48
870 
871 /* Crops */
872 #define FEAT_CROP_HEAD			0x81
873 #define FEAT_CROP_POTATO		0x81
874 #define FEAT_CROP_CABBAGE		0x82
875 #define FEAT_CROP_CARROT		0x83
876 #define FEAT_CROP_BEET			0x84
877 #define FEAT_CROP_SQUASH		0x85
878 #define FEAT_CROP_CORN			0x86
879 #define FEAT_CROP_MUSHROOM		0x87
880 #define FEAT_CROP_TAIL			0x88
881 
882 /* Special "home doors" */
883 #define FEAT_HOME_OPEN	0x51
884 #define FEAT_HOME_HEAD	0x71
885 #define FEAT_HOME_TAIL	0x78
886 
887 
888 /*** Artifact indexes (see "lib/edit/a_info.txt") ***/
889 
890 /* Lites */
891 #define ART_GALADRIEL		1
892 #define ART_ELENDIL			2
893 #define ART_THRAIN			3
894 #define ART_PALANTIR		7
895 
896 /* Amulets */
897 #define ART_CARLAMMAS		4
898 #define ART_INGWE			5
899 #define ART_DWARVES			6
900 #define ART_ELESSAR		14
901 #define ART_EVENSTAR		15
902 
903 /* Rings */
904 #define ART_BARAHIR			8
905 #define ART_TULKAS			9
906 #define ART_NARYA			10
907 #define ART_NENYA			11
908 #define ART_VILYA			12
909 #define ART_POWER			13
910 
911 /* Dragon Scale */
912 #define ART_RAZORBACK		16
913 #define ART_BLADETURNER		17
914 #define ART_MEDIATOR		18
915 
916 /* Hard Armour */
917 #define ART_SOULKEEPER		19
918 #define ART_ISILDUR			20
919 #define ART_ROHIRRIM		21
920 #define ART_BELEGENNON		22
921 #define ART_CELEBORN		23
922 #define ART_ARVEDUI			24
923 #define ART_CASPANION		25
924 
925 /* Soft Armour */
926 #define ART_HIMRING		26
927 #define ART_HITHLOMIR		27
928 #define ART_THALKETTOTH		28
929 
930 /* Shields */
931 #define ART_GILGALAD		29
932 #define ART_THORIN			30
933 #define ART_CELEGORM		31
934 #define ART_ANARION			32
935 
936 /* Helms and Crowns */
937 #define ART_CELEBRIMBOR		33
938 #define ART_MORGOTH			34
939 #define ART_BERUTHIEL		35
940 #define ART_THRANDUIL		36
941 #define ART_THENGEL			37
942 #define ART_HAMMERHAND		38
943 #define ART_DOR				39
944 #define ART_HOLHENNETH		40
945 #define ART_GORLIM			41
946 #define ART_GONDOR			42
947 #define ART_NUMENOR		43
948 
949 /* Cloaks */
950 #define ART_COLLUIN			44
951 #define ART_HOLCOLLETH		45
952 #define ART_THINGOL			46
953 #define ART_THORONGIL		47
954 #define ART_COLANNON		48
955 #define ART_LUTHIEN			49
956 #define ART_TUOR			50
957 
958 /* Gloves */
959 #define ART_EOL			51
960 #define ART_CAMBELEG		52
961 #define ART_CAMMITHRIM		53
962 #define ART_PAURHACH		54
963 #define ART_PAURNIMMEN		55
964 #define ART_PAURAEGEN		56
965 #define ART_PAURNEN			57
966 #define ART_CAMLOST			58
967 #define ART_FINGOLFIN		59
968 
969 /* Boots */
970 #define ART_FEANOR			60
971 #define ART_DAL				61
972 #define ART_THROR			62
973 #define ART_WORMTONGUE		63
974 
975 /* Swords */
976 #define ART_MAEDHROS		64
977 #define ART_ANGRIST			65
978 #define ART_NARTHANC		66
979 #define ART_NIMTHANC		67
980 #define ART_DETHANC			68
981 #define ART_RILIA			69
982 #define ART_BELANGIL		70
983 #define ART_CALRIS			71
984 #define ART_ARUNRUTH		72
985 #define ART_GLAMDRING		73
986 #define ART_AEGLIN			74
987 #define ART_ORCRIST			75
988 #define ART_GURTHANG		76
989 #define ART_ZARCUTHRA		77
990 #define ART_MORMEGIL		78
991 #define ART_GONDRICAM		79
992 #define ART_CRISDURIAN		80
993 #define ART_AGLARANG		81
994 #define ART_RINGIL			82
995 #define ART_ANDURIL			83
996 #define ART_ANGUIREL		84
997 #define ART_ELVAGIL			85
998 #define ART_FORASGIL		86
999 #define ART_CARETH			87
1000 #define ART_STING			88
1001 #define ART_HARADEKKET		89
1002 #define ART_GILETTAR		90
1003 #define ART_DOOMCALLER		91
1004 
1005 /* Polearms */
1006 #define ART_MELKOR		92
1007 #define ART_THEODEN			93
1008 #define ART_PAIN			94
1009 #define ART_OSONDIR			95
1010 #define ART_TIL				96
1011 #define ART_AEGLOS			97
1012 #define ART_OROME			98
1013 #define ART_NIMLOTH			99
1014 #define ART_EORLINGAS		100
1015 #define ART_DURIN			101
1016 #define ART_EONWE			102
1017 #define ART_BALLI			103
1018 #define ART_LOTHARANG		104
1019 #define ART_MUNDWINE		105
1020 #define ART_BARUKKHELED		106
1021 #define ART_WRATH			107
1022 #define ART_ULMO			108
1023 #define ART_AVAVIR			109
1024 #define ART_HURIN		110
1025 
1026 /* Hafted */
1027 #define ART_GROND			111
1028 #define ART_TOTILA			112
1029 #define ART_THUNDERFIST		113
1030 #define ART_BLOODSPIKE		114
1031 #define ART_FIRESTAR		115
1032 #define ART_TARATOL			116
1033 #define ART_AULE			117
1034 #define ART_NAR				118
1035 #define ART_ERIRIL			119
1036 #define ART_OLORIN			120
1037 #define ART_DEATHWREAKER	121
1038 #define ART_TURMIL			122
1039 #define ART_GOTHMOG		123
1040 
1041 /* Bows */
1042 #define ART_BELTHRONDING	124
1043 #define ART_BARD			125
1044 #define ART_CUBRAGOL		126
1045 #define ART_UMBAR		127
1046 #define ART_AMROD		128
1047 #define ART_AMRAS		129
1048 
1049 /* Digging Tools */
1050 #define ART_NAIN		130
1051 #define ART_EREBOR		131
1052 
1053 /* Miscellaneous new stuff */
1054 #define ART_FUNDIN		132
1055 #define ART_AZAGHAL		133
1056 #define ART_HARADRIM		134
1057 #define ART_NARSIL		135
1058 #define ART_EOWYN		136
1059 
1060 /* Randarts */
1061 #define ART_RANDART		137
1062 
1063 /* Randart rarity */
1064 #define RANDART_RARITY	60
1065 
1066 /* Option: randarts can be generated */
1067 #define RANDART
1068 
1069 
1070 /*** Ego-Item indexes (see "lib/edit/e_info.txt") ***/
1071 
1072 /* Nothing */
1073 /* xxx */
1074 /* xxx */
1075 /* xxx */
1076 
1077 /* Body Armor */
1078 #define EGO_RESIST_ACID		4
1079 #define EGO_RESIST_ELEC		5
1080 #define EGO_RESIST_FIRE		6
1081 #define EGO_RESIST_COLD		7
1082 #define EGO_RESISTANCE		8
1083 #define EGO_ELVENKIND		9
1084 #define EGO_ARMR_VULN		10
1085 #define EGO_PERMANENCE		11
1086 #define EGO_ARMR_DWARVEN	12
1087 /* xxx */
1088 /* xxx */
1089 /* xxx */
1090 
1091 /* Shields */
1092 #define EGO_ENDURE_ACID		16
1093 #define EGO_ENDURE_ELEC		17
1094 #define EGO_ENDURE_FIRE		18
1095 #define EGO_ENDURE_COLD		19
1096 #define EGO_ENDURANCE		20
1097 #define EGO_SHIELD_ELVENKIND	21
1098 #define EGO_SHIELD_PRESERVATION	22
1099 #define EGO_SHIELD_VULN		23
1100 
1101 /* Crowns and Helms */
1102 #define EGO_INTELLIGENCE	24
1103 #define EGO_WISDOM			25
1104 #define EGO_BEAUTY			26
1105 #define EGO_MAGI			27
1106 #define EGO_MIGHT			28
1107 #define EGO_LORDLINESS		29
1108 #define EGO_SEEING			30
1109 #define EGO_INFRAVISION		31
1110 #define EGO_LITE			32
1111 #define EGO_TELEPATHY		33
1112 #define EGO_REGENERATION	34
1113 #define EGO_TELEPORTATION	35
1114 #define EGO_SERENITY		36
1115 #define EGO_NITE_DAY		37
1116 #define EGO_DULLNESS		38
1117 #define EGO_SICKLINESS		39
1118 #define EGO_STUPIDITY		136
1119 #define EGO_NAIVETY		137
1120 #define EGO_UGLINESS		138
1121 
1122 
1123 /* Cloaks */
1124 #define EGO_PROTECTION		40
1125 #define EGO_STEALTH			41
1126 #define EGO_AMAN			42
1127 #define EGO_CLOAK_MAGI		43
1128 #define EGO_ENVELOPING		44
1129 #define EGO_VULNERABILITY	45
1130 #define EGO_IRRITATION		46
1131 /* xxx */
1132 
1133 /* Gloves */
1134 #define EGO_FREE_ACTION		48
1135 #define EGO_SLAYING			49
1136 #define EGO_AGILITY			50
1137 #define EGO_POWER			51
1138 #define EGO_GLOVES_THIEVERY	52
1139 #define EGO_GAUNTLETS_COMBAT	53
1140 #define EGO_WEAKNESS		54
1141 #define EGO_CLUMSINESS		55
1142 
1143 /* Boots */
1144 #define EGO_SLOW_DESCENT	56
1145 #define EGO_QUIET			57
1146 #define EGO_MOTION			58
1147 #define EGO_SPEED			59
1148 #define EGO_STABILITY		60
1149 #define EGO_NOISE			61
1150 #define EGO_SLOWNESS		62
1151 #define EGO_ANNOYANCE		63
1152 
1153 /* Weapons */
1154 #define EGO_HA				64
1155 #define EGO_DF				65
1156 #define EGO_BLESS_BLADE		66
1157 #define EGO_GONDOLIN		67
1158 #define EGO_WEST			68
1159 #define EGO_ATTACKS			69
1160 #define EGO_FURY			70
1161 /* xxx */
1162 #define EGO_BRAND_ACID		72
1163 #define EGO_BRAND_ELEC		73
1164 #define EGO_BRAND_FIRE		74
1165 #define EGO_BRAND_COLD		75
1166 #define EGO_BRAND_POIS		76
1167 /* xxx */
1168 /* xxx */
1169 /* xxx */
1170 #define EGO_SLAY_ANIMAL		80
1171 #define EGO_SLAY_EVIL		81
1172 #define EGO_SLAY_UNDEAD		82
1173 #define EGO_SLAY_DEMON		83
1174 #define EGO_SLAY_ORC		84
1175 #define EGO_SLAY_TROLL		85
1176 #define EGO_SLAY_GIANT		86
1177 #define EGO_SLAY_DRAGON		87
1178 #define EGO_KILL_ANIMAL		88
1179 #define EGO_KILL_EVIL		89
1180 #define EGO_KILL_UNDEAD		90
1181 #define EGO_KILL_DEMON		83
1182 #define EGO_KILL_ORC		84
1183 #define EGO_KILL_TROLL		85
1184 #define EGO_KILL_GIANT		86
1185 #define EGO_KILL_DRAGON		95
1186 /* xxx */
1187 /* xxx */
1188 /* xxx */
1189 /* xxx */
1190 #define EGO_DIGGING			100
1191 #define EGO_DIGGER_EARTHQUAKE		101
1192 #define EGO_MORGUL			102
1193 /* xxx */
1194 
1195 /* Bows */
1196 #define EGO_ACCURACY		104
1197 #define EGO_VELOCITY		105
1198 #define EGO_BOW_LORIEN		106
1199 #define EGO_CROSSBOW_HARAD	107
1200 #define EGO_EXTRA_MIGHT		108
1201 #define EGO_EXTRA_SHOTS		109
1202 #define EGO_SLING_BUCKLAND	110
1203 #define EGO_NAZGUL			111
1204 
1205 /* Ammo */
1206 #define EGO_HURT_ANIMAL		112
1207 #define EGO_HURT_EVIL		113
1208 #define EGO_HURT_UNDEAD		114
1209 #define EGO_HURT_DEMON		115
1210 #define EGO_HURT_ORC		116
1211 #define EGO_HURT_TROLL		117
1212 #define EGO_HURT_GIANT		118
1213 #define EGO_HURT_DRAGON		119
1214 #define EGO_AMMO_HOLY		120
1215 #define EGO_AMMO_VENOM		121
1216 #define EGO_FLAME			122
1217 #define EGO_FROST			123
1218 #define EGO_WOUNDING		124
1219 #define EGO_BACKBITING		125
1220 
1221 /* Broken items */
1222 #define EGO_SHATTERED		126
1223 #define EGO_BLASTED			127
1224 
1225 /* MAngband specific ego items */
1226 /* Shields */
1227 #define EGO_SHIELD_AVARI	128
1228 
1229 
1230 /* Cloaks */
1231 #define EGO_CLOAK_TELERI	129
1232 #define EGO_CLOAK_RES		131
1233 #define EGO_CLOAK_LORDLY_RES	130
1234 
1235 /* Gloves */
1236 #define EGO_ISTARI			132
1237 
1238 /* Boots */
1239 #define EGO_MIRKWOOD		133
1240 
1241 /* Missile launchers */
1242 #define EGO_LOTHLORIEN		106 /* note: this is angband,
1243 				     *	for mangband set to 134 */
1244 #define EGO_NUMENOR		135
1245 
1246 
1247 
1248 /*** Object "tval" and "sval" codes ***/
1249 
1250 
1251 /*
1252  * The values for the "tval" field of various objects.
1253  *
1254  * This value is the primary means by which items are sorted in the
1255  * player inventory, followed by "sval" and "cost".
1256  *
1257  * Note that a "BOW" with tval = 19 and sval S = 10*N+P takes a missile
1258  * weapon with tval = 16+N, and does (xP) damage when so combined.  This
1259  * fact is not actually used in the source, but it kind of interesting.
1260  *
1261  * Note that as of 2.7.8, the "item flags" apply to all items, though
1262  * only armor and weapons and a few other items use any of these flags.
1263  */
1264 
1265 #define TV_SKELETON      1	/* Skeletons ('s') */
1266 #define TV_BOTTLE		 2	/* Empty bottles ('!') */
1267 #define TV_JUNK          3	/* Sticks, Pottery, etc ('~') */
1268 
1269 #define TV_SPIKE         5	/* Spikes ('~') */
1270 #define TV_CHEST         7	/* Chests ('~') */
1271 #define TV_SHOT			16	/* Ammo for slings */
1272 #define TV_ARROW        17	/* Ammo for bows */
1273 #define TV_BOLT         18	/* Ammo for x-bows */
1274 #define TV_BOW          19	/* Slings/Bows/Xbows */
1275 #define TV_DIGGING      20	/* Shovels/Picks */
1276 #define TV_HAFTED       21	/* Priest Weapons */
1277 #define TV_POLEARM      22	/* Axes and Pikes */
1278 #define TV_SWORD        23	/* Edged Weapons */
1279 #define TV_BOOTS        30	/* Boots */
1280 #define TV_GLOVES       31	/* Gloves */
1281 #define TV_HELM         32	/* Helms */
1282 #define TV_CROWN        33	/* Crowns */
1283 #define TV_SHIELD       34	/* Shields */
1284 #define TV_CLOAK        35	/* Cloaks */
1285 #define TV_SOFT_ARMOR   36	/* Soft Armor */
1286 #define TV_HARD_ARMOR   37	/* Hard Armor */
1287 #define TV_DRAG_ARMOR	38	/* Dragon Scale Mail */
1288 #define TV_LITE         39	/* Lites (including Specials) */
1289 #define TV_AMULET       40	/* Amulets (including Specials) */
1290 #define TV_RING         45	/* Rings (including Specials) */
1291 #define TV_STAFF        55
1292 #define TV_WAND         65
1293 #define TV_ROD          66
1294 #define TV_SCROLL       70
1295 #define TV_POTION       75
1296 #define TV_FLASK        77
1297 #define TV_FOOD         80
1298 #define TV_MAGIC_BOOK   90
1299 #define TV_PRAYER_BOOK  91
1300 #define TV_GOLD         100	/* Gold can only be picked up by players */
1301 
1302 
1303 /* Maximum "tval" */
1304 #define TV_MAX		100
1305 
1306 
1307 /* The "sval" codes for TV_GOLD (mostly calculated at runtime) */
1308 #define SV_PLAYER_GOLD	9
1309 
1310 /* The "sval" codes for TV_SHOT/TV_ARROW/TV_BOLT */
1311 #define SV_AMMO_LIGHT		0	/* pebbles */
1312 #define SV_AMMO_NORMAL		1	/* shots, arrows, bolts */
1313 #define SV_AMMO_HEAVY		2	/* seeker arrows and bolts */
1314 #define SV_AMMO_MITHRIL			3	/* mithril shots, arrows, bolts */
1315 #define SV_AMMO_MAGIC			4	/* magic shots, arrows, bolts */
1316 
1317 /* The "sval" codes for TV_BOW (note information in "sval") */
1318 #define SV_SLING			2	/* (x2) */
1319 #define SV_SHORT_BOW		12	/* (x2) */
1320 #define SV_LONG_BOW			13	/* (x3) */
1321 #define SV_LIGHT_XBOW		23	/* (x3) */
1322 #define SV_HEAVY_XBOW		24	/* (x4) */
1323 
1324 /* The "sval" codes for TV_DIGGING */
1325 #define SV_SHOVEL			1
1326 #define SV_GNOMISH_SHOVEL	2
1327 #define SV_DWARVEN_SHOVEL	3
1328 #define SV_PICK				4
1329 #define SV_ORCISH_PICK		5
1330 #define SV_DWARVEN_PICK		6
1331 #define SV_MATTOCK			7
1332 
1333 /* The "sval" values for TV_HAFTED */
1334 #define SV_WHIP				2	/* 1d3 */
1335 #define SV_QUARTERSTAFF			3	/* 1d9 */
1336 #define SV_MACE					5	/* 2d4 */
1337 #define SV_BALL_AND_CHAIN		6	/* 2d4 */
1338 #define SV_WAR_HAMMER			8	/* 3d3 */
1339 #define SV_LUCERN_HAMMER		10	/* 2d5 */
1340 #define SV_MORNING_STAR			12	/* 2d6 */
1341 #define SV_FLAIL				13	/* 2d6 */
1342 #define SV_LEAD_FILLED_MACE		15	/* 3d4 */
1343 #define SV_TWO_HANDED_FLAIL		18	/* 3d6 */
1344 #define SV_MACE_OF_DISRUPTION	20	/* 5d8 */
1345 #define SV_GROND				50	/* 3d4 */
1346 
1347 /* The "sval" values for TV_POLEARM */
1348 #define SV_SPEAR				2	/* 1d6 */
1349 #define SV_AWL_PIKE				4	/* 1d8 */
1350 #define SV_TRIDENT				5	/* 1d9 */
1351 #define SV_PIKE					8	/* 2d5 */
1352 #define SV_BEAKED_AXE			10	/* 2d6 */
1353 #define SV_BROAD_AXE			11	/* 2d6 */
1354 #define SV_GLAIVE				13	/* 2d6 */
1355 #define SV_HALBERD				15	/* 3d4 */
1356 #define SV_SCYTHE				17	/* 5d3 */
1357 #define SV_LANCE				20	/* 2d8 */
1358 #define SV_BATTLE_AXE			22	/* 2d8 */
1359 #define SV_GREAT_AXE			25	/* 4d4 */
1360 #define SV_LOCHABER_AXE			28	/* 3d8 */
1361 #define SV_SCYTHE_OF_SLICING	30	/* 8d4 */
1362 
1363 /* The "sval" codes for TV_SWORD */
1364 #define SV_BROKEN_DAGGER		1	/* 1d1 */
1365 #define SV_BROKEN_SWORD			2	/* 1d2 */
1366 #define SV_DAGGER				4	/* 1d4 */
1367 #define SV_MAIN_GAUCHE			5	/* 1d5 */
1368 #define SV_RAPIER				7	/* 1d6 */
1369 #define SV_SMALL_SWORD			8	/* 1d6 */
1370 #define SV_SHORT_SWORD			10	/* 1d7 */
1371 #define SV_SABRE				11	/* 1d7 */
1372 #define SV_CUTLASS				12	/* 1d7 */
1373 #define SV_TULWAR				15	/* 2d4 */
1374 #define SV_BROAD_SWORD			16	/* 2d5 */
1375 #define SV_LONG_SWORD			17	/* 2d5 */
1376 #define SV_SCIMITAR				18	/* 2d5 */
1377 #define SV_KATANA				20	/* 3d4 */
1378 #define SV_BASTARD_SWORD		21	/* 3d4 */
1379 #define SV_TWO_HANDED_SWORD		25	/* 3d6 */
1380 #define SV_EXECUTIONERS_SWORD	28	/* 4d5 */
1381 #define SV_BLADE_OF_CHAOS		30	/* 6d5 */
1382 
1383 /* The "sval" codes for TV_SHIELD */
1384 #define SV_SMALL_LEATHER_SHIELD		2
1385 #define SV_SMALL_METAL_SHIELD		3
1386 #define SV_LARGE_LEATHER_SHIELD		4
1387 #define SV_LARGE_METAL_SHIELD		5
1388 #define SV_ORCISH_SHIELD                7
1389 #define SV_SHIELD_OF_DEFLECTION		10
1390 
1391 /* The "sval" codes for TV_HELM */
1392 #define SV_HARD_LEATHER_CAP		2
1393 #define SV_METAL_CAP			3
1394 #define SV_IRON_HELM			5
1395 #define SV_STEEL_HELM			6
1396 #define SV_IRON_CROWN			10
1397 #define SV_GOLDEN_CROWN			11
1398 #define SV_JEWELED_CROWN		12
1399 #define SV_MORGOTH				50
1400 
1401 /* The "sval" codes for TV_BOOTS */
1402 #define SV_PAIR_OF_SOFT_LEATHER_BOOTS	2
1403 #define SV_PAIR_OF_HARD_LEATHER_BOOTS	3
1404 #define SV_PAIR_OF_METAL_SHOD_BOOTS     6
1405 #define SV_PAIR_OF_WITAN_BOOTS          8
1406 
1407 /* The "sval" codes for TV_CLOAK */
1408 #define SV_CLOAK					1
1409 #define SV_KOLLA                                        3
1410 #define SV_SHADOW_CLOAK				6
1411 
1412 /* The "sval" codes for TV_GLOVES */
1413 #define SV_SET_OF_LEATHER_GLOVES	1
1414 #define SV_SET_OF_GAUNTLETS			2
1415 #define SV_SET_OF_ELVEN_GLOVES			4
1416 #define SV_SET_OF_CESTI				5
1417 
1418 /* The "sval" codes for TV_SOFT_ARMOR */
1419 #define SV_FILTHY_RAG				1
1420 #define SV_ROBE						2
1421 #define SV_SOFT_LEATHER_ARMOR		4
1422 #define SV_SOFT_STUDDED_LEATHER		5
1423 #define SV_HARD_LEATHER_ARMOR		6
1424 #define SV_HARD_STUDDED_LEATHER		7
1425 #define SV_LEATHER_SCALE_MAIL		11
1426 
1427 /* The "sval" codes for TV_HARD_ARMOR */
1428 #define SV_RUSTY_CHAIN_MAIL			1	/* 14- */
1429 #define SV_METAL_SCALE_MAIL			3	/* 13 */
1430 #define SV_CHAIN_MAIL				4	/* 14 */
1431 #define SV_AUGMENTED_CHAIN_MAIL		6	/* 16 */
1432 #define SV_DOUBLE_CHAIN_MAIL		7	/* 16 */
1433 #define SV_BAR_CHAIN_MAIL			8	/* 18 */
1434 #define SV_METAL_BRIGANDINE_ARMOUR	9	/* 19 */
1435 #define SV_PARTIAL_PLATE_ARMOUR		12	/* 22 */
1436 #define SV_METAL_LAMELLAR_ARMOUR	13	/* 23 */
1437 #define SV_FULL_PLATE_ARMOUR		15	/* 25 */
1438 #define SV_RIBBED_PLATE_ARMOUR		18	/* 28 */
1439 #define SV_MITHRIL_CHAIN_MAIL		20	/* 28+ */
1440 #define SV_MITHRIL_PLATE_MAIL		25	/* 35+ */
1441 #define SV_ADAMANTITE_PLATE_MAIL	30	/* 40+ */
1442 
1443 /* The "sval" codes for TV_DRAG_ARMOR */
1444 #define SV_DRAGON_BLACK			1
1445 #define SV_DRAGON_BLUE			2
1446 #define SV_DRAGON_WHITE			3
1447 #define SV_DRAGON_RED			4
1448 #define SV_DRAGON_GREEN			5
1449 #define SV_DRAGON_MULTIHUED		6
1450 #define SV_DRAGON_SHINING		10
1451 #define SV_DRAGON_LAW			12
1452 #define SV_DRAGON_BRONZE		14
1453 #define SV_DRAGON_GOLD			16
1454 #define SV_DRAGON_CHAOS			18
1455 #define SV_DRAGON_BALANCE		20
1456 #define SV_DRAGON_POWER			30
1457 
1458 /* The sval codes for TV_LITE */
1459 #define SV_LITE_TORCH		0
1460 #define SV_LITE_LANTERN		1
1461 #define SV_LITE_DWARVEN		2
1462 #define SV_LITE_FEANOR		3
1463 #define SV_LITE_GALADRIEL	4
1464 #define SV_LITE_ELENDIL		5
1465 #define SV_LITE_THRAIN		6
1466 #define SV_LITE_PALANTIR		7
1467 
1468 /* The "sval" codes for TV_AMULET */
1469 #define SV_AMULET_DOOM			0
1470 #define SV_AMULET_TELEPORT		1
1471 #define SV_AMULET_ADORNMENT		2
1472 #define SV_AMULET_SLOW_DIGEST	3
1473 #define SV_AMULET_RESIST_ACID	4
1474 #define SV_AMULET_SEARCHING		5
1475 #define SV_AMULET_WISDOM		6
1476 #define SV_AMULET_CHARISMA		7
1477 #define SV_AMULET_THE_MAGI		8
1478 #define SV_AMULET_SUSTENANCE		9
1479 #define SV_AMULET_CARLAMMAS		10
1480 #define SV_AMULET_INGWE			11
1481 #define SV_AMULET_DWARVES		12
1482 #define SV_AMULET_ESP			13
1483 #define SV_AMULET_RESIST		14
1484 #define SV_AMULET_REGEN			15
1485 #define SV_AMULET_ELESSAR		16
1486 #define SV_AMULET_EVENSTAR		17
1487 #define SV_AMULET_DEVOTION		18
1488 #define SV_AMULET_WEPMASTERY		19
1489 #define SV_AMULET_TRICKERY		20
1490 #define SV_AMULET_INFRA			21
1491 #define SV_AMULET_RESIST_ELEC		22
1492 #define SV_AMULET_THE_MOON              23
1493 #define SV_AMULET_TERKEN		24
1494 #define SV_AMULET_SPEED			25
1495 
1496 /* The sval codes for TV_RING */
1497 #define SV_RING_WOE				0
1498 #define SV_RING_AGGRAVATION		1
1499 #define SV_RING_WEAKNESS		2
1500 #define SV_RING_STUPIDITY		3
1501 #define SV_RING_TELEPORTATION	4
1502 #define SV_RING_SLOW_DIGESTION	6
1503 #define SV_RING_FEATHER_FALL	7
1504 #define SV_RING_RESIST_FIRE		8
1505 #define SV_RING_RESIST_COLD		9
1506 #define SV_RING_SUSTAIN_STR		10
1507 #define SV_RING_SUSTAIN_INT		11
1508 #define SV_RING_SUSTAIN_WIS		12
1509 #define SV_RING_SUSTAIN_DEX		13
1510 #define SV_RING_SUSTAIN_CON		14
1511 #define SV_RING_SUSTAIN_CHR		15
1512 #define SV_RING_PROTECTION		16
1513 #define SV_RING_ACID			17
1514 #define SV_RING_FLAMES			18
1515 #define SV_RING_ICE				19
1516 #define SV_RING_RESIST_POIS		20
1517 #define SV_RING_FREE_ACTION		21
1518 #define SV_RING_SEE_INVIS		22
1519 #define SV_RING_SEARCHING		23
1520 #define SV_RING_STR				24
1521 #define SV_RING_INT				25
1522 #define SV_RING_DEX				26
1523 #define SV_RING_CON				27
1524 #define SV_RING_ACCURACY		28
1525 #define SV_RING_DAMAGE			29
1526 #define SV_RING_SLAYING			30
1527 #define SV_RING_SPEED			31
1528 #define SV_RING_BARAHIR			32
1529 #define SV_RING_TULKAS			33
1530 #define SV_RING_NARYA			34
1531 #define SV_RING_NENYA			35
1532 #define SV_RING_VILYA			36
1533 #define SV_RING_POWER			37
1534 #define SV_RING_LIGHTNING		38
1535 
1536 /* The "sval" codes for TV_STAFF */
1537 #define SV_STAFF_DARKNESS		0
1538 #define SV_STAFF_SLOWNESS		1
1539 #define SV_STAFF_HASTE_MONSTERS	2
1540 #define SV_STAFF_SUMMONING		3
1541 #define SV_STAFF_TELEPORTATION	4
1542 #define SV_STAFF_IDENTIFY		5
1543 #define SV_STAFF_REMOVE_CURSE	6
1544 #define SV_STAFF_STARLITE		7
1545 #define SV_STAFF_LITE			8
1546 #define SV_STAFF_MAPPING		9
1547 #define SV_STAFF_DETECT_GOLD	10
1548 #define SV_STAFF_DETECT_ITEM	11
1549 #define SV_STAFF_DETECT_TRAP	12
1550 #define SV_STAFF_DETECT_DOOR	13
1551 #define SV_STAFF_DETECT_INVIS	14
1552 #define SV_STAFF_DETECT_EVIL	15
1553 #define SV_STAFF_CURE_LIGHT		16
1554 #define SV_STAFF_CURING			17
1555 #define SV_STAFF_HEALING		18
1556 #define SV_STAFF_THE_MAGI		19
1557 #define SV_STAFF_SLEEP_MONSTERS	20
1558 #define SV_STAFF_SLOW_MONSTERS	21
1559 #define SV_STAFF_SPEED			22
1560 #define SV_STAFF_PROBING		23
1561 #define SV_STAFF_DISPEL_EVIL	24
1562 #define SV_STAFF_POWER			25
1563 #define SV_STAFF_HOLINESS		26
1564 #define SV_STAFF_BANISHMENT		27
1565 #define SV_STAFF_EARTHQUAKES	28
1566 #define SV_STAFF_DESTRUCTION	29
1567 
1568 /* The "sval" codes for TV_WAND */
1569 #define SV_WAND_HEAL_MONSTER	0
1570 #define SV_WAND_HASTE_MONSTER	1
1571 #define SV_WAND_CLONE_MONSTER	2
1572 #define SV_WAND_TELEPORT_AWAY	3
1573 #define SV_WAND_DISARMING		4
1574 #define SV_WAND_TRAP_DOOR_DEST	5
1575 #define SV_WAND_STONE_TO_MUD	6
1576 #define SV_WAND_LITE			7
1577 #define SV_WAND_SLEEP_MONSTER	8
1578 #define SV_WAND_SLOW_MONSTER	9
1579 #define SV_WAND_CONFUSE_MONSTER	10
1580 #define SV_WAND_FEAR_MONSTER	11
1581 #define SV_WAND_DRAIN_LIFE		12
1582 #define SV_WAND_POLYMORPH		13
1583 #define SV_WAND_STINKING_CLOUD	14
1584 #define SV_WAND_MAGIC_MISSILE	15
1585 #define SV_WAND_ACID_BOLT		16
1586 #define SV_WAND_ELEC_BOLT		17
1587 #define SV_WAND_FIRE_BOLT		18
1588 #define SV_WAND_COLD_BOLT		19
1589 #define SV_WAND_ACID_BALL		20
1590 #define SV_WAND_ELEC_BALL		21
1591 #define SV_WAND_FIRE_BALL		22
1592 #define SV_WAND_COLD_BALL		23
1593 #define SV_WAND_WONDER			24
1594 #define SV_WAND_ANNIHILATION	25
1595 #define SV_WAND_DRAGON_FIRE		26
1596 #define SV_WAND_DRAGON_COLD		27
1597 #define SV_WAND_DRAGON_BREATH	28
1598 
1599 /* The "sval" codes for TV_ROD */
1600 #define SV_ROD_DETECT_TRAP		0
1601 #define SV_ROD_DETECT_DOOR		1
1602 #define SV_ROD_IDENTIFY			2
1603 #define SV_ROD_RECALL			3
1604 #define SV_ROD_ILLUMINATION		4
1605 #define SV_ROD_MAPPING			5
1606 #define SV_ROD_DETECTION		6
1607 #define SV_ROD_PROBING			7
1608 #define SV_ROD_CURING			8
1609 #define SV_ROD_HEALING			9
1610 #define SV_ROD_RESTORATION		10
1611 #define SV_ROD_SPEED			11
1612 #define SV_ROD_TELEPORT_AWAY	13
1613 #define SV_ROD_DISARMING		14
1614 #define SV_ROD_LITE				15
1615 #define SV_ROD_SLEEP_MONSTER	16
1616 #define SV_ROD_SLOW_MONSTER		17
1617 #define SV_ROD_DRAIN_LIFE		18
1618 #define SV_ROD_POLYMORPH		19
1619 #define SV_ROD_ACID_BOLT		20
1620 #define SV_ROD_ELEC_BOLT		21
1621 #define SV_ROD_FIRE_BOLT		22
1622 #define SV_ROD_COLD_BOLT		23
1623 #define SV_ROD_ACID_BALL		24
1624 #define SV_ROD_ELEC_BALL		25
1625 #define SV_ROD_FIRE_BALL		26
1626 #define SV_ROD_COLD_BALL		27
1627 
1628 /* The "sval" codes for TV_SCROLL */
1629 #define SV_SCROLL_DARKNESS				0
1630 #define SV_SCROLL_AGGRAVATE_MONSTER		1
1631 #define SV_SCROLL_CURSE_ARMOR			2
1632 #define SV_SCROLL_CURSE_WEAPON			3
1633 #define SV_SCROLL_SUMMON_MONSTER		4
1634 #define SV_SCROLL_SUMMON_UNDEAD			5
1635 #define SV_SCROLL_CREATE_ARTIFACT 		6
1636 #define SV_SCROLL_TRAP_CREATION			7
1637 #define SV_SCROLL_PHASE_DOOR			8
1638 #define SV_SCROLL_TELEPORT				9
1639 #define SV_SCROLL_TELEPORT_LEVEL		10
1640 #define SV_SCROLL_WORD_OF_RECALL		11
1641 #define SV_SCROLL_IDENTIFY				12
1642 #define SV_SCROLL_STAR_IDENTIFY			13
1643 #define SV_SCROLL_REMOVE_CURSE			14
1644 #define SV_SCROLL_STAR_REMOVE_CURSE		15
1645 #define SV_SCROLL_ENCHANT_ARMOR			16
1646 #define SV_SCROLL_ENCHANT_WEAPON_TO_HIT	17
1647 #define SV_SCROLL_ENCHANT_WEAPON_TO_DAM	18
1648 #define SV_SCROLL_STAR_ENCHANT_ARMOR	20
1649 #define SV_SCROLL_STAR_ENCHANT_WEAPON	21
1650 #define SV_SCROLL_RECHARGING			22
1651 #define SV_SCROLL_LIGHT					24
1652 #define SV_SCROLL_MAPPING				25
1653 #define SV_SCROLL_DETECT_GOLD			26
1654 #define SV_SCROLL_DETECT_ITEM			27
1655 #define SV_SCROLL_DETECT_TRAP			28
1656 #define SV_SCROLL_DETECT_DOOR			29
1657 #define SV_SCROLL_DETECT_INVIS			30
1658 #define SV_SCROLL_SATISFY_HUNGER		32
1659 #define SV_SCROLL_BLESSING				33
1660 #define SV_SCROLL_HOLY_CHANT			34
1661 #define SV_SCROLL_HOLY_PRAYER			35
1662 #define SV_SCROLL_MONSTER_CONFUSION		36
1663 #define SV_SCROLL_PROTECTION_FROM_EVIL	37
1664 #define SV_SCROLL_RUNE_OF_PROTECTION	38
1665 #define SV_SCROLL_TRAP_DOOR_DESTRUCTION	39
1666 #define SV_SCROLL_STAR_DESTRUCTION		41
1667 #define SV_SCROLL_DISPEL_UNDEAD			42
1668 #define SV_SCROLL_BANISHMENT			44
1669 #define SV_SCROLL_MASS_BANISHMENT		45
1670 #define SV_SCROLL_ACQUIREMENT			46
1671 #define SV_SCROLL_STAR_ACQUIREMENT		47
1672 #define SV_SCROLL_LIFE				48
1673 #define SV_SCROLL_CREATE_HOUSE			49
1674 
1675 /* The "sval" codes for TV_POTION */
1676 #define SV_POTION_WATER				0
1677 #define SV_POTION_APPLE_JUICE		1
1678 #define SV_POTION_SLIME_MOLD		2
1679 #define SV_POTION_SLOWNESS			4
1680 #define SV_POTION_SALT_WATER		5
1681 #define SV_POTION_POISON			6
1682 #define SV_POTION_BLINDNESS			7
1683 #define SV_POTION_CONFUSION			9
1684 #define SV_POTION_SLEEP				11
1685 #define SV_POTION_LOSE_MEMORIES		13
1686 #define SV_POTION_RUINATION			15
1687 #define SV_POTION_DEC_STR			16
1688 #define SV_POTION_DEC_INT			17
1689 #define SV_POTION_DEC_WIS			18
1690 #define SV_POTION_DEC_DEX			19
1691 #define SV_POTION_DEC_CON			20
1692 #define SV_POTION_DEC_CHR			21
1693 #define SV_POTION_DETONATIONS		22
1694 #define SV_POTION_DEATH				23
1695 #define SV_POTION_INFRAVISION		24
1696 #define SV_POTION_DETECT_INVIS		25
1697 #define SV_POTION_SLOW_POISON		26
1698 #define SV_POTION_CURE_POISON		27
1699 #define SV_POTION_BOLDNESS			28
1700 #define SV_POTION_SPEED				29
1701 #define SV_POTION_RESIST_HEAT		30
1702 #define SV_POTION_RESIST_COLD		31
1703 #define SV_POTION_HEROISM			32
1704 #define SV_POTION_BERSERK_STRENGTH	33
1705 #define SV_POTION_CURE_LIGHT		34
1706 #define SV_POTION_CURE_SERIOUS		35
1707 #define SV_POTION_CURE_CRITICAL		36
1708 #define SV_POTION_HEALING			37
1709 #define SV_POTION_STAR_HEALING		38
1710 #define SV_POTION_LIFE				39
1711 #define SV_POTION_RESTORE_MANA		40
1712 #define SV_POTION_RESTORE_EXP		41
1713 #define SV_POTION_RES_STR			42
1714 #define SV_POTION_RES_INT			43
1715 #define SV_POTION_RES_WIS			44
1716 #define SV_POTION_RES_DEX			45
1717 #define SV_POTION_RES_CON			46
1718 #define SV_POTION_RES_CHR			47
1719 #define SV_POTION_INC_STR			48
1720 #define SV_POTION_INC_INT			49
1721 #define SV_POTION_INC_WIS			50
1722 #define SV_POTION_INC_DEX			51
1723 #define SV_POTION_INC_CON			52
1724 #define SV_POTION_INC_CHR			53
1725 #define SV_POTION_AUGMENTATION			55
1726 #define SV_POTION_ENLIGHTENMENT			56
1727 #define SV_POTION_STAR_ENLIGHTENMENT	57
1728 #define SV_POTION_SELF_KNOWLEDGE		58
1729 #define SV_POTION_EXPERIENCE			59
1730 
1731 /* The "sval" codes for TV_FOOD */
1732 #define SV_FOOD_POISON			0
1733 #define SV_FOOD_BLINDNESS		1
1734 #define SV_FOOD_PARANOIA		2
1735 #define SV_FOOD_CONFUSION		3
1736 #define SV_FOOD_HALLUCINATION	4
1737 #define SV_FOOD_PARALYSIS		5
1738 #define SV_FOOD_WEAKNESS		6
1739 #define SV_FOOD_SICKNESS		7
1740 #define SV_FOOD_STUPIDITY		8
1741 #define SV_FOOD_NAIVETY			9
1742 #define SV_FOOD_UNHEALTH		10
1743 #define SV_FOOD_DISEASE			11
1744 #define SV_FOOD_CURE_POISON		12
1745 #define SV_FOOD_CURE_BLINDNESS	13
1746 #define SV_FOOD_CURE_PARANOIA	14
1747 #define SV_FOOD_CURE_CONFUSION	15
1748 #define SV_FOOD_CURE_SERIOUS	16
1749 #define SV_FOOD_RESTORE_STR		17
1750 #define SV_FOOD_RESTORE_CON		18
1751 #define SV_FOOD_RESTORING		19
1752 
1753 /* crops */
1754 #define	SV_FOOD_POTATO			20
1755 #define SV_FOOD_HEAD_OF_CABBAGE		21
1756 #define SV_FOOD_CARROT			22
1757 #define SV_FOOD_BEET			23
1758 #define	SV_FOOD_SQUASH			24
1759 #define	SV_FOOD_EAR_OF_CORN		25
1760 
1761 #define SV_FOOD_BISCUIT			32
1762 #define SV_FOOD_JERKY			33
1763 #define SV_FOOD_RATION			35
1764 #define SV_FOOD_SLIME_MOLD		36
1765 #define SV_FOOD_WAYBREAD		37
1766 #define SV_FOOD_PINT_OF_ALE		38
1767 #define SV_FOOD_PINT_OF_WINE		39
1768 
1769 /* The "sval" codes for TV_JUNK */
1770 #define SV_HOUSE_FOUNDATION		9
1771 
1772 /*
1773  * Special "sval" limit -- first "normal" food
1774  */
1775 #define SV_FOOD_MIN_FOOD	20
1776 
1777 /*
1778  * Special "sval" limit -- first "aimed" rod
1779  */
1780 #define SV_ROD_MIN_DIRECTION	12
1781 
1782 /*
1783  * Special "sval" limit -- first "large" chest
1784  */
1785 #define SV_CHEST_MIN_LARGE	4
1786 
1787 /*
1788  * Special "sval" limit -- first "good" magic/prayer book
1789  */
1790 #define SV_BOOK_MIN_GOOD	4
1791 
1792 
1793 /*
1794  * Special "sval" value -- unknown "sval"
1795  */
1796 #define SV_UNKNOWN			255
1797 
1798 
1799 /*
1800  * Some bit-flags for the "smart" field
1801  */
1802 #define SM_RES_ACID		0x00000001
1803 #define SM_RES_ELEC		0x00000002
1804 #define SM_RES_FIRE		0x00000004
1805 #define SM_RES_COLD		0x00000008
1806 #define SM_RES_POIS		0x00000010
1807 #define SM_RES_NETH		0x00000020
1808 #define SM_RES_LITE		0x00000040
1809 #define SM_RES_DARK		0x00000080
1810 #define SM_RES_FEAR		0x00000100
1811 #define SM_RES_CONF		0x00000200
1812 #define SM_RES_CHAOS	0x00000400
1813 #define SM_RES_DISEN	0x00000800
1814 #define SM_RES_BLIND	0x00001000
1815 #define SM_RES_NEXUS	0x00002000
1816 #define SM_RES_SOUND	0x00004000
1817 #define SM_RES_SHARD	0x00008000
1818 #define SM_OPP_ACID		0x00010000
1819 #define SM_OPP_ELEC		0x00020000
1820 #define SM_OPP_FIRE		0x00040000
1821 #define SM_OPP_COLD		0x00080000
1822 #define SM_OPP_POIS		0x00100000
1823 #define SM_OPP_XXX1		0x00200000
1824 #define SM_OPP_XXX2		0x00400000
1825 #define SM_OPP_XXX3		0x00800000
1826 #define SM_IMM_ACID		0x01000000
1827 #define SM_IMM_ELEC		0x02000000
1828 #define SM_IMM_FIRE		0x04000000
1829 #define SM_IMM_COLD		0x08000000
1830 #define SM_IMM_XXX5		0x10000000
1831 #define SM_IMM_XXX6		0x20000000
1832 #define SM_IMM_FREE		0x40000000
1833 #define SM_IMM_MANA		0x80000000
1834 
1835 /*** General flag values ***/
1836 
1837 
1838 /*
1839  * Special cave grid flags
1840  */
1841 #define CAVE_MARK	0x01 	/* memorized feature */
1842 #define CAVE_GLOW	0x02 	/* self-illuminating */
1843 #define CAVE_ICKY	0x04 	/* part of a vault */
1844 #define CAVE_ROOM	0x08 	/* part of a room */
1845 #define CAVE_LITE	0x10 	/* lite flag  */
1846 #define CAVE_VIEW	0x20 	/* view flag */
1847 #define CAVE_TEMP	0x40 	/* temp flag */
1848 #define CAVE_XTRA	0x80 	/* misc flag */
1849 
1850 
1851 
1852 /*
1853  * Bit flags for the "project()" function
1854  *
1855  *   JUMP: Jump directly to the target location (this is a hack)
1856  *   BEAM: Work as a beam weapon (affect every grid passed through)
1857  *   THRU: Continue "through" the target (used for "bolts"/"beams")
1858  *   STOP: Stop as soon as we hit a monster (used for "bolts")
1859  *   GRID: Affect each grid in the "blast area" in some way
1860  *   ITEM: Affect each object in the "blast area" in some way
1861  *   KILL: Affect each monster in the "blast area" in some way
1862  *   HIDE: Hack -- disable "visual" feedback from projection
1863  */
1864 #define PROJECT_JUMP	0x01
1865 #define PROJECT_BEAM	0x02
1866 #define PROJECT_THRU	0x04
1867 #define PROJECT_STOP	0x08
1868 #define PROJECT_GRID	0x10
1869 #define PROJECT_ITEM	0x20
1870 #define PROJECT_KILL	0x40
1871 #define PROJECT_HIDE	0x80
1872 
1873 /*
1874  * Bit flags for the "enchant()" function
1875  */
1876 #define ENCH_TOHIT   0x01
1877 #define ENCH_TODAM   0x02
1878 #define ENCH_TOAC    0x04
1879 
1880 /*** General index values ***/
1881 
1882 
1883 /*
1884  * Spell types used by project(), and related functions.
1885  */
1886 #define GF_ELEC         1
1887 #define GF_POIS         2
1888 #define GF_ACID         3
1889 #define GF_COLD         4
1890 #define GF_FIRE         5
1891 #define GF_BOULDER      8  /* Thrown boulder */
1892 #define GF_BOLT         9  /* Crossbow shot */
1893 #define GF_MISSILE      10 /* Magic missile */
1894 #define GF_ARROW        11
1895 #define GF_PLASMA       12
1896 #define GF_HOLY_ORB     13
1897 #define GF_WATER        14
1898 #define GF_LITE         15
1899 #define GF_DARK         16
1900 #define GF_LITE_WEAK	17
1901 #define GF_DARK_WEAK	18
1902 #define GF_SHARDS       20
1903 #define GF_SOUND        21
1904 #define GF_CONFUSION    22
1905 #define GF_FORCE        23
1906 #define GF_INERT        24 /* GF_INERTIA */
1907 #define GF_MANA         26
1908 #define GF_METEOR       27
1909 #define GF_ICE          28
1910 #define GF_CHAOS        30
1911 #define GF_NETHER       31
1912 #define GF_DISENCHANT   32
1913 #define GF_NEXUS        33
1914 #define GF_TIME         34
1915 #define GF_GRAVITY      35
1916 #define GF_KILL_WALL	40
1917 #define GF_KILL_DOOR	41
1918 #define GF_KILL_TRAP	42
1919 #define GF_MAKE_WALL	45
1920 #define GF_MAKE_DOOR	46
1921 #define GF_MAKE_TRAP	47
1922 #define GF_OLD_CLONE	51
1923 #define GF_OLD_POLY		52
1924 #define GF_OLD_HEAL		53
1925 #define GF_OLD_SPEED	54
1926 #define GF_OLD_SLOW		55
1927 #define GF_OLD_CONF		56
1928 #define GF_OLD_SLEEP	57
1929 #define GF_OLD_DRAIN	58
1930 #define GF_AWAY_UNDEAD	61
1931 #define GF_AWAY_EVIL	62
1932 #define GF_AWAY_ALL	63
1933 #define GF_TURN_UNDEAD	64
1934 #define GF_TURN_EVIL	65
1935 #define GF_TURN_ALL	66
1936 #define GF_DISP_UNDEAD	67
1937 #define GF_DISP_EVIL	68
1938 #define GF_DISP_ALL	69
1939 #define	GF_HEAL_PLAYER	70
1940 #define GF_PROJECT_SPELL 71
1941 #define GF_PROJECT_PRAYER 72
1942 
1943 #define GF_MAX 73
1944 
1945 /*
1946  * Some things which induce learning
1947  */
1948 #define DRS_ACID	1
1949 #define DRS_ELEC	2
1950 #define DRS_FIRE	3
1951 #define DRS_COLD	4
1952 #define DRS_POIS	5
1953 #define DRS_NETH	6
1954 #define DRS_LITE	7
1955 #define DRS_DARK	8
1956 #define DRS_FEAR	9
1957 #define DRS_CONF	10
1958 #define DRS_CHAOS	11
1959 #define DRS_DISEN	12
1960 #define DRS_BLIND	13
1961 #define DRS_NEXUS	14
1962 #define DRS_SOUND	15
1963 #define DRS_SHARD	16
1964 #define DRS_FREE	30
1965 #define DRS_MANA	31
1966 
1967 
1968 
1969 /*
1970  * Hack -- first "normal" artifact in the artifact list.  All of
1971  * the artifacts with indexes from 1 to 15 are "special" (lights,
1972  * rings, amulets), and the ones from 16 to 127 are "normal".
1973  */
1974 #define ART_MIN_NORMAL		16
1975 
1976 
1977 /*
1978  * Hack -- special "xtra" object powers
1979  */
1980 
1981 /* Sustain one stat */
1982 #define EGO_XTRA_SUSTAIN	1
1983 
1984 /* High resist */
1985 #define EGO_XTRA_POWER		2
1986 
1987 /* Special ability */
1988 #define EGO_XTRA_ABILITY	3
1989 
1990 
1991 
1992 
1993 
1994 /*** Object flag values ***/
1995 
1996 
1997 /*
1998  * Chest trap flags (see "tables.c")
1999  */
2000 #define CHEST_LOSE_STR		0x01
2001 #define CHEST_LOSE_CON		0x02
2002 #define CHEST_POISON		0x04
2003 #define CHEST_PARALYZE		0x08
2004 #define CHEST_EXPLODE		0x10
2005 #define CHEST_SUMMON		0x20
2006 
2007 
2008 
2009 /*
2010  * Special "Item Flags"
2011  */
2012 #define ID_SENSE	0x01	/* Item has been "sensed" */
2013 #define ID_FIXED	0x02	/* Item has been "haggled" */
2014 #define ID_EMPTY	0x04	/* Item charges are known */
2015 #define ID_KNOWN	0x08	/* Item abilities are known */
2016 #define ID_RUMOUR	0x10	/* Item background is known */
2017 #define ID_MENTAL	0x20	/* Item information is known */
2018 #define ID_CURSED	0x40	/* Item is temporarily cursed */
2019 #define ID_BROKEN	0x80	/* Item is permanently worthless */
2020 
2021 
2022 
2023 /*
2024  * As of 2.7.8, the "object flags" are valid for all objects, and as
2025  * of 2.7.9, these flags are not actually stored with the object.
2026  *
2027  * Note that "flags1" contains all flags dependant on "pval" (including
2028  * stat bonuses, but NOT stat sustainers), plus all "extra attack damage"
2029  * flags (SLAY_XXX and BRAND_XXX).
2030  *
2031  * Note that "flags2" contains all "resistances" (including "Stat Sustainers",
2032  * actual immunities, and resistances).  Note that "Hold Life" is really an
2033  * "immunity" to ExpLoss, and "Free Action" is "immunity to paralysis".
2034  *
2035  * Note that "flags3" contains everything else -- including the three "CURSED"
2036  * flags, and the "BLESSED" flag, several "item display" parameters, some new
2037  * flags for powerful Bows, and flags which affect the player in a "general"
2038  * way (LITE, TELEPATHY, SEE_INVIS, SLOW_DIGEST, REGEN, FEATHER), including
2039  * all the "general" curses (TELEPORT, AGGRAVATE, EXP_DRAIN).  It also has
2040  * four new flags called "ITEM_IGNORE_XXX" which lets an item specify that
2041  * it can not be affected by various forms of destruction.  This is NOT as
2042  * powerful as actually granting resistance/immunity to the wearer.
2043  */
2044 
2045 #define TR1_STR             0x00000001L /* STR += "pval" */
2046 #define TR1_INT             0x00000002L /* INT += "pval" */
2047 #define TR1_WIS             0x00000004L /* WIS += "pval" */
2048 #define TR1_DEX             0x00000008L /* DEX += "pval" */
2049 #define TR1_CON             0x00000010L /* CON += "pval" */
2050 #define TR1_CHR             0x00000020L /* CHR += "pval" */
2051 #define TR1_XXX1            0x00000040L /* (reserved) */
2052 #define TR1_XXX2            0x00000080L /* (reserved) */
2053 #define TR1_STEALTH         0x00000100L /* Stealth += "pval" */
2054 #define TR1_SEARCH          0x00000200L /* Search += "pval" */
2055 #define TR1_INFRA           0x00000400L /* Infra += "pval" */
2056 #define TR1_TUNNEL          0x00000800L /* Tunnel += "pval" */
2057 #define TR1_SPEED           0x00001000L /* Speed += "pval" */
2058 #define TR1_BLOWS           0x00002000L /* Blows += "pval" */
2059 #define TR1_SHOTS           0x00004000L /* Shots += "pval" */
2060 #define TR1_MIGHT           0x00008000L /* Might += "pval" */
2061 #define TR1_SLAY_ANIMAL     0x00010000L /* Weapon slays animals */
2062 #define TR1_SLAY_EVIL       0x00020000L /* Weapon slays evil */
2063 #define TR1_SLAY_UNDEAD     0x00040000L /* Weapon slays undead */
2064 #define TR1_SLAY_DEMON      0x00080000L /* Weapon slays demon */
2065 #define TR1_SLAY_ORC        0x00100000L /* Weapon slays orc */
2066 #define TR1_SLAY_TROLL      0x00200000L /* Weapon slays troll */
2067 #define TR1_SLAY_GIANT      0x00400000L /* Weapon slays giant */
2068 #define TR1_SLAY_DRAGON     0x00800000L /* Weapon slays dragon */
2069 #define TR1_KILL_DRAGON     0x01000000L /* Weapon kills dragon */
2070 #define TR1_KILL_DEMON      0x02000000L /* Weapon kills demon */
2071 #define TR1_KILL_UNDEAD     0x04000000L /* Weapon "kills" undead */
2072 #define TR1_BRAND_POIS      0x08000000L /* Weapon has poison brand */
2073 #define TR1_BRAND_ACID      0x10000000L /* Weapon has acid brand */
2074 #define TR1_BRAND_ELEC      0x20000000L /* Weapon has elec brand */
2075 #define TR1_BRAND_FIRE      0x40000000L /* Weapon has fire brand */
2076 #define TR1_BRAND_COLD      0x80000000L /* Weapon has cold brand */
2077 
2078 #define TR2_SUST_STR        0x00000001L /* Sustain STR */
2079 #define TR2_SUST_INT        0x00000002L /* Sustain INT */
2080 #define TR2_SUST_WIS        0x00000004L /* Sustain WIS */
2081 #define TR2_SUST_DEX        0x00000008L /* Sustain DEX */
2082 #define TR2_SUST_CON        0x00000010L /* Sustain CON */
2083 #define TR2_SUST_CHR        0x00000020L /* Sustain CHR */
2084 #define TR2_XXX1            0x00000040L /* (reserved) */
2085 #define TR2_XXX2            0x00000080L /* (reserved) */
2086 #define TR2_XXX3            0x00000100L /* (reserved) */
2087 #define TR2_XXX4            0x00000200L /* (reserved) */
2088 #define TR2_XXX5            0x00000400L /* (reserved) */
2089 #define TR2_XXX6            0x00000800L /* (reserved) */
2090 #define TR2_IM_ACID         0x00001000L /* Immunity to acid */
2091 #define TR2_IM_ELEC         0x00002000L /* Immunity to elec */
2092 #define TR2_IM_FIRE         0x00004000L /* Immunity to fire */
2093 #define TR2_IM_COLD         0x00008000L /* Immunity to cold */
2094 #define TR2_RES_ACID        0x00010000L /* Resist acid */
2095 #define TR2_RES_ELEC        0x00020000L /* Resist elec */
2096 #define TR2_RES_FIRE        0x00040000L /* Resist fire */
2097 #define TR2_RES_COLD        0x00080000L /* Resist cold */
2098 #define TR2_RES_POIS        0x00100000L /* Resist poison */
2099 #define TR2_RES_FEAR        0x00200000L /* Resist fear */
2100 #define TR2_RES_LITE        0x00400000L /* Resist lite */
2101 #define TR2_RES_DARK        0x00800000L /* Resist dark */
2102 #define TR2_RES_BLIND       0x01000000L /* Resist blind */
2103 #define TR2_RES_CONFU       0x02000000L /* Resist confusion */
2104 #define TR2_RES_SOUND       0x04000000L /* Resist sound */
2105 #define TR2_RES_SHARD       0x08000000L /* Resist shards */
2106 #define TR2_RES_NEXUS       0x10000000L /* Resist nexus */
2107 #define TR2_RES_NETHR       0x20000000L /* Resist nether */
2108 #define TR2_RES_CHAOS       0x40000000L /* Resist chaos */
2109 #define TR2_RES_DISEN       0x80000000L /* Resist disenchant */
2110 
2111 #define TR3_SLOW_DIGEST     0x00000001L /* Slow digest */
2112 #define TR3_FEATHER         0x00000002L /* Feather Falling */
2113 #define TR3_LITE            0x00000004L /* Perma-Lite */
2114 #define TR3_REGEN           0x00000008L /* Regeneration */
2115 #define TR3_TELEPATHY       0x00000010L /* Telepathy */
2116 #define TR3_SEE_INVIS       0x00000020L /* See Invis */
2117 #define TR3_FREE_ACT        0x00000040L /* Free action */
2118 #define TR3_HOLD_LIFE       0x00000080L /* Hold life */
2119 #define TR3_XXX1            0x00000100L
2120 #define TR3_XXX2            0x00000200L
2121 #define TR3_XXX3            0x00000400L
2122 #define TR3_XXX4            0x00000800L
2123 #define TR3_IMPACT          0x00001000L /* Earthquake blows */
2124 #define TR3_TELEPORT        0x00002000L /* Random teleportation */
2125 #define TR3_AGGRAVATE       0x00004000L /* Aggravate monsters */
2126 #define TR3_DRAIN_EXP       0x00008000L /* Experience drain */
2127 #define TR3_IGNORE_ACID     0x00010000L /* Item ignores Acid Damage */
2128 #define TR3_IGNORE_ELEC     0x00020000L /* Item ignores Elec Damage */
2129 #define TR3_IGNORE_FIRE     0x00040000L /* Item ignores Fire Damage */
2130 #define TR3_IGNORE_COLD     0x00080000L /* Item ignores Cold Damage */
2131 #define TR3_XXX5            0x00100000L /* (reserved) */
2132 #define TR3_XXX6            0x00200000L /* (reserved) */
2133 #define TR3_BLESSED         0x00400000L /* Item has been blessed */
2134 #define TR3_ACTIVATE        0x00800000L /* Item can be activated */
2135 #define TR3_INSTA_ART       0x01000000L /* Item makes an artifact */
2136 #define TR3_EASY_KNOW       0x02000000L /* Item is known if aware */
2137 #define TR3_HIDE_TYPE       0x04000000L /* Item hides description */
2138 #define TR3_SHOW_MODS       0x08000000L /* Item shows Tohit/Todam */
2139 #define TR3_XXX7            0x10000000L /* (reserved) */
2140 #define TR3_LIGHT_CURSE     0x20000000L /* Item has Light Curse */
2141 #define TR3_HEAVY_CURSE     0x40000000L /* Item has Heavy Curse */
2142 #define TR3_PERMA_CURSE     0x80000000L /* Item has Perma Curse */
2143 
2144 
2145 /*
2146  * Hack -- flag set 1 -- mask for "pval-dependant" flags.
2147  * Note that all "pval" dependant flags must be in "flags1".
2148  */
2149 #define TR1_PVAL_MASK \
2150 	(TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | \
2151 	 TR1_CON | TR1_CHR | TR1_XXX1 | TR1_XXX2 | \
2152 	 TR1_STEALTH | TR1_SEARCH | TR1_INFRA | TR1_TUNNEL | \
2153 	 TR1_SPEED | TR1_BLOWS | TR1_SHOTS | TR1_MIGHT)
2154 
2155 
2156 /*
2157  * Flag set 3 -- mask for "ignore element" flags.
2158  */
2159 #define TR3_IGNORE_MASK \
2160 	(TR3_IGNORE_ACID | TR3_IGNORE_ELEC | TR3_IGNORE_FIRE | \
2161 	 TR3_IGNORE_COLD )
2162 
2163 /*
2164  * Hack -- special "xtra" object flag info (type)
2165  */
2166 #define OBJECT_XTRA_TYPE_SUSTAIN	1
2167 #define OBJECT_XTRA_TYPE_RESIST		2
2168 #define OBJECT_XTRA_TYPE_POWER		3
2169 
2170 /*
2171  * Hack -- special "xtra" object flag info (what flag set)
2172  */
2173 #define OBJECT_XTRA_WHAT_SUSTAIN	2
2174 #define OBJECT_XTRA_WHAT_RESIST		2
2175 #define OBJECT_XTRA_WHAT_POWER		3
2176 
2177 /*
2178  * Hack -- special "xtra" object flag info (base flag value)
2179  */
2180 #define OBJECT_XTRA_BASE_SUSTAIN	TR2_SUST_STR
2181 #define OBJECT_XTRA_BASE_RESIST		TR2_RES_POIS
2182 #define OBJECT_XTRA_BASE_POWER		TR3_SLOW_DIGEST
2183 
2184 /*
2185  * Hack -- special "xtra" object flag info (number of flags)
2186  */
2187 #define OBJECT_XTRA_SIZE_SUSTAIN	6
2188 #define OBJECT_XTRA_SIZE_RESIST		12
2189 #define OBJECT_XTRA_SIZE_POWER		8
2190 
2191 
2192 /*** Class flags ***/
2193 
2194 #define CF_EXTRA_SHOT		0x00000001L	/* Extra shots */
2195 #define CF_BRAVERY_30		0x00000002L	/* Gains resist fear at plev 30 */
2196 #define CF_BLESS_WEAPON		0x00000004L	/* Requires blessed/hafted weapons */
2197 #define CF_CUMBER_GLOVE		0x00000008L	/* Gloves disturb spellcasting */
2198 #define CF_ZERO_FAIL		0x00000010L /* Fail rates can reach 0% */
2199 #define CF_BEAM				0x00000020L /* Higher chance of spells beaming */
2200 #define CF_CHOOSE_SPELLS	0x00000040L	/* Allow choice of spells */
2201 #define CF_PSEUDO_ID_HEAVY	0x00000080L /* Allow heavy pseudo-id */
2202 #define CF_PSEUDO_ID_IMPROV	0x00000100L /* Pseudo-id improves quicker with player-level */
2203 #define CF_XXX10			0x00000200L
2204 #define CF_XXX11			0x00000400L
2205 #define CF_XXX12			0x00000800L
2206 #define CF_XXX13			0x00001000L
2207 #define CF_XXX14			0x00002000L
2208 #define CF_XXX15			0x00004000L
2209 #define CF_XXX16			0x00008000L
2210 #define CF_BACK_STAB   		0x00010000L /* Extra damage to sleeping or fleeing creatures */
2211 #define CF_STEALTH_MODE		0x00020000L /* Trade speed for stealth instead of searching */
2212 #define CF_STEALING_IMPROV 	0x00040000L /* Stealing improves quicker with player-level */
2213 #define CF_SPEED_BONUS 		0x00080000L /* Gain 1 additional speed point every 5 levels */
2214 #define CF_HP_BONUS			0x00100000L /* Gain 1 additional hit point on levelup */
2215 #define CF_XXX22			0x00200000L
2216 #define CF_XXX23			0x00400000L
2217 #define CF_XXX24			0x00800000L
2218 #define CF_XXX25			0x01000000L
2219 #define CF_XXX26			0x02000000L
2220 #define CF_XXX27			0x04000000L
2221 #define CF_XXX28			0x08000000L
2222 #define CF_XXX29			0x10000000L
2223 #define CF_XXX30			0x20000000L
2224 #define CF_XXX31			0x40000000L
2225 #define CF_XXX32			0x80000000L
2226 
2227 
2228 /*** Monster blow constants ***/
2229 
2230 
2231 /*
2232  * New monster blow methods
2233  */
2234 #define RBM_HIT		1
2235 #define RBM_TOUCH	2
2236 #define RBM_PUNCH	3
2237 #define RBM_KICK	4
2238 #define RBM_CLAW	5
2239 #define RBM_BITE	6
2240 #define RBM_STING	7
2241 #define RBM_XXX1	8
2242 #define RBM_BUTT	9
2243 #define RBM_CRUSH	10
2244 #define RBM_ENGULF	11
2245 #define RBM_XXX2	12
2246 #define RBM_CRAWL	13
2247 #define RBM_DROOL	14
2248 #define RBM_SPIT	15
2249 #define RBM_XXX3	16
2250 #define RBM_GAZE	17
2251 #define RBM_WAIL	18
2252 #define RBM_SPORE	19
2253 #define RBM_XXX4	20
2254 #define RBM_BEG		21
2255 #define RBM_INSULT	22
2256 #define RBM_MOAN	23
2257 #define RBM_XXX5	24
2258 
2259 
2260 /*
2261  * New monster blow effects
2262  */
2263 #define RBE_HURT		1
2264 #define RBE_POISON		2
2265 #define RBE_UN_BONUS	3
2266 #define RBE_UN_POWER	4
2267 #define RBE_EAT_GOLD	5
2268 #define RBE_EAT_ITEM	6
2269 #define RBE_EAT_FOOD	7
2270 #define RBE_EAT_LITE	8
2271 #define RBE_ACID		9
2272 #define RBE_ELEC		10
2273 #define RBE_FIRE		11
2274 #define RBE_COLD		12
2275 #define RBE_BLIND		13
2276 #define RBE_CONFUSE		14
2277 #define RBE_TERRIFY		15
2278 #define RBE_PARALYZE	16
2279 #define RBE_LOSE_STR	17
2280 #define RBE_LOSE_INT	18
2281 #define RBE_LOSE_WIS	19
2282 #define RBE_LOSE_DEX	20
2283 #define RBE_LOSE_CON	21
2284 #define RBE_LOSE_CHR	22
2285 #define RBE_LOSE_ALL	23
2286 #define RBE_SHATTER		24
2287 #define RBE_EXP_10		25
2288 #define RBE_EXP_20		26
2289 #define RBE_EXP_40		27
2290 #define RBE_EXP_80		28
2291 #define RBE_HALLU		29
2292 
2293 
2294 /*** Monster flag values (hard-coded) ***/
2295 
2296 
2297 /*
2298  * New monster race bit flags
2299  */
2300 #define RF1_UNIQUE			0x00000001	/* Unique Monster */
2301 #define RF1_QUESTOR			0x00000002	/* Quest Monster */
2302 #define RF1_MALE			0x00000004	/* Male gender */
2303 #define RF1_FEMALE			0x00000008	/* Female gender */
2304 #define RF1_CHAR_CLEAR		0x00000010	/* Absorbs symbol */
2305 #define RF1_CHAR_MULTI		0x00000020	/* Changes symbol */
2306 #define RF1_ATTR_CLEAR		0x00000040	/* Absorbs color */
2307 #define RF1_ATTR_MULTI		0x00000080	/* Changes color */
2308 #define RF1_FORCE_DEPTH		0x00000100	/* Start at "correct" depth */
2309 #define RF1_FORCE_MAXHP		0x00000200	/* Start with max hitpoints */
2310 #define RF1_FORCE_SLEEP		0x00000400	/* Start out sleeping */
2311 #define RF1_FORCE_EXTRA		0x00000800	/* Start out something */
2312 #define RF1_FRIEND			0x00001000	/* Arrive with a friend */
2313 #define RF1_FRIENDS			0x00002000	/* Arrive with some friends */
2314 #define RF1_ESCORT			0x00004000	/* Arrive with an escort */
2315 #define RF1_ESCORTS			0x00008000	/* Arrive with some escorts */
2316 #define RF1_NEVER_BLOW		0x00010000	/* Never make physical blow */
2317 #define RF1_NEVER_MOVE		0x00020000	/* Never make physical move */
2318 #define RF1_RAND_25			0x00040000	/* Moves randomly (25%) */
2319 #define RF1_RAND_50			0x00080000	/* Moves randomly (50%) */
2320 #define RF1_ONLY_GOLD		0x00100000	/* Drop only gold */
2321 #define RF1_ONLY_ITEM		0x00200000	/* Drop only items */
2322 #define RF1_DROP_60			0x00400000	/* Drop an item/gold (60%) */
2323 #define RF1_DROP_90			0x00800000	/* Drop an item/gold (90%) */
2324 #define RF1_DROP_1D2		0x01000000	/* Drop 1d2 items/gold */
2325 #define RF1_DROP_2D2		0x02000000	/* Drop 2d2 items/gold */
2326 #define RF1_DROP_3D2		0x04000000	/* Drop 3d2 items/gold */
2327 #define RF1_DROP_4D2		0x08000000	/* Drop 4d2 items/gold */
2328 #define RF1_DROP_GOOD		0x10000000	/* Drop good items */
2329 #define RF1_DROP_GREAT		0x20000000	/* Drop great items */
2330 #define RF1_DROP_USEFUL		0x40000000	/* Drop "useful" items */
2331 #define RF1_DROP_CHOSEN		0x80000000	/* Drop "chosen" items */
2332 
2333 /*
2334  * New monster race bit flags
2335  */
2336 #define RF2_STUPID			0x00000001	/* Monster is stupid */
2337 #define RF2_SMART			0x00000002	/* Monster is smart */
2338 #define RF2_XXX1			0x00000004	/* (?) */
2339 #define RF2_XXX2			0x00000008	/* (?) */
2340 #define RF2_INVISIBLE		0x00000010	/* Monster avoids vision */
2341 #define RF2_COLD_BLOOD		0x00000020	/* Monster avoids infra */
2342 #define RF2_EMPTY_MIND		0x00000040	/* Monster avoids telepathy */
2343 #define RF2_WEIRD_MIND		0x00000080	/* Monster avoids telepathy? */
2344 #define RF2_MULTIPLY		0x00000100	/* Monster reproduces */
2345 #define RF2_REGENERATE		0x00000200	/* Monster regenerates */
2346 #define RF2_XXX3			0x00000400	/* (?) */
2347 #define RF2_XXX4			0x00000800	/* (?) */
2348 #define RF2_POWERFUL		0x00001000	/* Monster has strong breath */
2349 #define RF2_XXX5			0x00002000	/* (?) */
2350 #define RF2_XXX7			0x00004000	/* (?) */
2351 #define RF2_XXX6			0x00008000	/* (?) */
2352 #define RF2_OPEN_DOOR		0x00010000	/* Monster can open doors */
2353 #define RF2_BASH_DOOR		0x00020000	/* Monster can bash doors */
2354 #define RF2_PASS_WALL		0x00040000	/* Monster can pass walls */
2355 #define RF2_KILL_WALL		0x00080000	/* Monster can destroy walls */
2356 #define RF2_MOVE_BODY		0x00100000	/* Monster can move monsters */
2357 #define RF2_KILL_BODY		0x00200000	/* Monster can kill monsters */
2358 #define RF2_TAKE_ITEM		0x00400000	/* Monster can pick up items */
2359 #define RF2_KILL_ITEM		0x00800000	/* Monster can crush items */
2360 #define RF2_WANDERER		0x01000000	/* Town wanderers */
2361 #define RF2_BRAIN_2			0x02000000
2362 #define RF2_BRAIN_3			0x04000000
2363 #define RF2_BRAIN_4			0x08000000
2364 #define RF2_BRAIN_5			0x10000000
2365 #define RF2_BRAIN_6			0x20000000
2366 #define RF2_BRAIN_7			0x40000000
2367 #define RF2_BRAIN_8			0x80000000
2368 
2369 /*
2370  * New monster race bit flags
2371  */
2372 #define RF3_ORC				0x00000001	/* Orc */
2373 #define RF3_TROLL			0x00000002	/* Troll */
2374 #define RF3_GIANT			0x00000004	/* Giant */
2375 #define RF3_DRAGON			0x00000008	/* Dragon */
2376 #define RF3_DEMON			0x00000010	/* Demon */
2377 #define RF3_UNDEAD			0x00000020	/* Undead */
2378 #define RF3_EVIL			0x00000040	/* Evil */
2379 #define RF3_ANIMAL			0x00000080	/* Animal */
2380 #define RF3_XXX1			0x00000100	/* (?) */
2381 #define RF3_XXX2			0x00000200	/* (?) */
2382 #define RF3_XXX3			0x00000400	/* Non-Vocal (?) */
2383 #define RF3_XXX4			0x00000800	/* Non-Living (?) */
2384 #define RF3_HURT_LITE		0x00001000	/* Hurt by lite */
2385 #define RF3_HURT_ROCK		0x00002000	/* Hurt by rock remover */
2386 #define RF3_HURT_FIRE		0x00004000	/* Hurt badly by fire */
2387 #define RF3_HURT_COLD		0x00008000	/* Hurt badly by cold */
2388 #define RF3_IM_ACID			0x00010000	/* Resist acid a lot */
2389 #define RF3_IM_ELEC			0x00020000	/* Resist elec a lot */
2390 #define RF3_IM_FIRE			0x00040000	/* Resist fire a lot */
2391 #define RF3_IM_COLD			0x00080000	/* Resist cold a lot */
2392 #define RF3_IM_POIS			0x00100000	/* Resist poison a lot */
2393 #define RF3_XXX5			0x00200000	/* Immune to (?) */
2394 #define RF3_RES_NETH		0x00400000	/* Resist nether a lot */
2395 #define RF3_RES_WATE		0x00800000	/* Resist water */
2396 #define RF3_RES_PLAS		0x01000000	/* Resist plasma */
2397 #define RF3_RES_NEXU		0x02000000	/* Resist nexus */
2398 #define RF3_RES_DISE		0x04000000	/* Resist disenchantment */
2399 #define RF3_XXX6			0x08000000	/* Resist (?) */
2400 #define RF3_NO_FEAR			0x10000000	/* Cannot be scared */
2401 #define RF3_NO_STUN			0x20000000	/* Cannot be stunned */
2402 #define RF3_NO_CONF			0x40000000	/* Cannot be confused */
2403 #define RF3_NO_SLEEP		0x80000000	/* Cannot be slept */
2404 
2405 /*
2406  * New monster race bit flags
2407  */
2408 #define RF4_SHRIEK			0x00000001	/* Shriek for help */
2409 #define RF4_XXX2			0x00000002	/* (?) */
2410 #define RF4_XXX3			0x00000004	/* (?) */
2411 #define RF4_XXX4			0x00000008	/* (?) */
2412 #define RF4_ARROW_1			0x00000010	/* Fire an arrow (light) */
2413 #define RF4_ARROW_2			0x00000020	/* Fire an arrow (heavy) */
2414 #define RF4_ARROW_3			0x00000040	/* Fire missiles (light) */
2415 #define RF4_ARROW_4			0x00000080	/* Fire missiles (heavy) */
2416 #define RF4_BR_ACID			0x00000100	/* Breathe Acid */
2417 #define RF4_BR_ELEC			0x00000200	/* Breathe Elec */
2418 #define RF4_BR_FIRE			0x00000400	/* Breathe Fire */
2419 #define RF4_BR_COLD			0x00000800	/* Breathe Cold */
2420 #define RF4_BR_POIS			0x00001000	/* Breathe Poison */
2421 #define RF4_BR_NETH			0x00002000	/* Breathe Nether */
2422 #define RF4_BR_LITE			0x00004000	/* Breathe Lite */
2423 #define RF4_BR_DARK			0x00008000	/* Breathe Dark */
2424 #define RF4_BR_CONF			0x00010000	/* Breathe Confusion */
2425 #define RF4_BR_SOUN			0x00020000	/* Breathe Sound */
2426 #define RF4_BR_CHAO			0x00040000	/* Breathe Chaos */
2427 #define RF4_BR_DISE			0x00080000	/* Breathe Disenchant */
2428 #define RF4_BR_NEXU			0x00100000	/* Breathe Nexus */
2429 #define RF4_BR_TIME			0x00200000	/* Breathe Time */
2430 #define RF4_BR_INER			0x00400000	/* Breathe Inertia */
2431 #define RF4_BR_GRAV			0x00800000	/* Breathe Gravity */
2432 #define RF4_BR_SHAR			0x01000000	/* Breathe Shards */
2433 #define RF4_BR_PLAS			0x02000000	/* Breathe Plasma */
2434 #define RF4_BR_WALL			0x04000000	/* Breathe Force */
2435 #define RF4_BR_MANA			0x08000000	/* Breathe Mana */
2436 #define RF4_XXX5			0x10000000
2437 #define RF4_XXX6			0x20000000
2438 #define RF4_XXX7			0x40000000
2439 #define RF4_BOULDER			0x80000000	/* Throw a boulder */
2440 
2441 /*
2442  * New monster race bit flags
2443  */
2444 #define RF5_BA_ACID			0x00000001	/* Acid Ball */
2445 #define RF5_BA_ELEC			0x00000002	/* Elec Ball */
2446 #define RF5_BA_FIRE			0x00000004	/* Fire Ball */
2447 #define RF5_BA_COLD			0x00000008	/* Cold Ball */
2448 #define RF5_BA_POIS			0x00000010	/* Poison Ball */
2449 #define RF5_BA_NETH			0x00000020	/* Nether Ball */
2450 #define RF5_BA_WATE			0x00000040	/* Water Ball */
2451 #define RF5_BA_MANA			0x00000080	/* Mana Storm */
2452 #define RF5_BA_DARK			0x00000100	/* Darkness Storm */
2453 #define RF5_DRAIN_MANA		0x00000200	/* Drain Mana */
2454 #define RF5_MIND_BLAST		0x00000400	/* Blast Mind */
2455 #define RF5_BRAIN_SMASH		0x00000800	/* Smash Brain */
2456 #define RF5_CAUSE_1			0x00001000	/* Cause Light Wound */
2457 #define RF5_CAUSE_2			0x00002000	/* Cause Serious Wound */
2458 #define RF5_CAUSE_3			0x00004000	/* Cause Critical Wound */
2459 #define RF5_CAUSE_4			0x00008000	/* Cause Mortal Wound */
2460 #define RF5_BO_ACID			0x00010000	/* Acid Bolt */
2461 #define RF5_BO_ELEC			0x00020000	/* Elec Bolt (unused) */
2462 #define RF5_BO_FIRE			0x00040000	/* Fire Bolt */
2463 #define RF5_BO_COLD			0x00080000	/* Cold Bolt */
2464 #define RF5_BO_POIS			0x00100000	/* Poison Bolt (unused) */
2465 #define RF5_BO_NETH			0x00200000	/* Nether Bolt */
2466 #define RF5_BO_WATE			0x00400000	/* Water Bolt */
2467 #define RF5_BO_MANA			0x00800000	/* Mana Bolt */
2468 #define RF5_BO_PLAS			0x01000000	/* Plasma Bolt */
2469 #define RF5_BO_ICEE			0x02000000	/* Ice Bolt */
2470 #define RF5_MISSILE			0x04000000	/* Magic Missile */
2471 #define RF5_SCARE			0x08000000	/* Frighten Player */
2472 #define RF5_BLIND			0x10000000	/* Blind Player */
2473 #define RF5_CONF			0x20000000	/* Confuse Player */
2474 #define RF5_SLOW			0x40000000	/* Slow Player */
2475 #define RF5_HOLD			0x80000000	/* Paralyze Player */
2476 
2477 /*
2478  * New monster race bit flags
2479  */
2480 #define RF6_HASTE			0x00000001	/* Speed self */
2481 #define RF6_XXX1			0x00000002	/* Speed a lot (?) */
2482 #define RF6_HEAL			0x00000004	/* Heal self */
2483 #define RF6_XXX2			0x00000008	/* Heal a lot (?) */
2484 #define RF6_BLINK			0x00000010	/* Teleport Short */
2485 #define RF6_TPORT			0x00000020	/* Teleport Long */
2486 #define RF6_XXX3			0x00000040	/* Move to Player (?) */
2487 #define RF6_XXX4			0x00000080	/* Move to Monster (?) */
2488 #define RF6_TELE_TO			0x00000100	/* Move player to monster */
2489 #define RF6_TELE_AWAY		0x00000200	/* Move player far away */
2490 #define RF6_TELE_LEVEL		0x00000400	/* Move player vertically */
2491 #define RF6_XXX5			0x00000800	/* Move player (?) */
2492 #define RF6_DARKNESS		0x00001000	/* Create Darkness */
2493 #define RF6_TRAPS			0x00002000	/* Create Traps */
2494 #define RF6_FORGET			0x00004000	/* Cause amnesia */
2495 #define RF6_XXX6			0x00008000	/* ??? */
2496 #define RF6_S_KIN			0x00010000	/* Summon Kin */
2497 #define RF6_S_HI_DEMON			0x00020000	/*  Summon Greater Demons */
2498 #define RF6_S_MONSTER		0x00040000	/* Summon Monster */
2499 #define RF6_S_MONSTERS		0x00080000	/* Summon Monsters */
2500 #define RF6_S_ANIMAL			0x00100000	/* Summon Animals */
2501 #define RF6_S_SPIDER		0x00200000	/* Summon Spiders */
2502 #define RF6_S_HOUND			0x00400000	/* Summon Hounds */
2503 #define RF6_S_HYDRA			0x00800000	/* Summon Hydras */
2504 #define RF6_S_ANGEL			0x01000000	/* Summon Angel */
2505 #define RF6_S_DEMON			0x02000000	/* Summon Demon */
2506 #define RF6_S_UNDEAD		0x04000000	/* Summon Undead */
2507 #define RF6_S_DRAGON		0x08000000	/* Summon Dragon */
2508 #define RF6_S_HI_UNDEAD		0x10000000	/* Summon Greater Undead */
2509 #define RF6_S_HI_DRAGON		0x20000000	/* Summon Ancient Dragon */
2510 #define RF6_S_WRAITH		0x40000000	/* Summon Unique Wraith */
2511 #define RF6_S_UNIQUE		0x80000000	/* Summon Unique Monster */
2512 
2513 
2514 /*
2515  * Some flags are obvious
2516  */
2517 #define RF1_OBVIOUS_MASK \
2518 	(RF1_UNIQUE | RF1_QUESTOR | RF1_MALE | RF1_FEMALE | \
2519 	 RF1_FRIEND | RF1_FRIENDS | RF1_ESCORT | RF1_ESCORTS)
2520 
2521 /*
2522  * "race" flags
2523  */
2524 #define RF3_RACE_MASK \
2525 	(RF3_ORC | RF3_TROLL | RF3_GIANT | RF3_DRAGON | \
2526 	 RF3_DEMON | RF3_UNDEAD | RF3_EVIL | RF3_ANIMAL)
2527 
2528 
2529 
2530 /*
2531 	Different types of terrain, used for the wilderness.
2532 	-APD-
2533 
2534 	HACK -- I am temporarily using these numbers to determine
2535 	how many monsters to generate.
2536 */
2537 
2538 #define		WILD_LAKE		0
2539 #define		WILD_GRASSLAND		1
2540 #define		WILD_FOREST		2
2541 #define		WILD_SWAMP		20
2542 #define		WILD_DENSEFOREST	15
2543 #define		WILD_WASTELAND		7
2544 #define		WILD_UNDEFINED		8
2545 #define		WILD_CLONE		9 /* we should copy the terrain type of a neighbor */
2546 #define		WILD_TOWN		10
2547 
2548 /* different buildings */
2549 #define		WILD_LOG_CABIN		0
2550 #define		WILD_ROCK_HOME		1
2551 #define		WILD_PERM_HOME		2
2552 #define		WILD_SHACK		3
2553 #define		WILD_TOWN_HOME		4
2554 #define		WILD_ARENA		8
2555 
2556 /* types of crops */
2557 #define		WILD_CROP_POTATO	0
2558 #define		WILD_CROP_CABBAGE	1
2559 #define		WILD_CROP_CARROT	2
2560 #define		WILD_CROP_BEET		3
2561 #define		WILD_CROP_MUSHROOM	4
2562 #define		WILD_CROP_SQUASH	5
2563 #define		WILD_CROP_CORN		6
2564 
2565 /* used for wilderness generation */
2566 #define		DIR_NORTH		0
2567 #define		DIR_EAST		1
2568 #define		DIR_SOUTH		2
2569 #define		DIR_WEST		3
2570 
2571 /* wilderness flags */
2572 
2573 #define		WILD_F_GENERATED	1
2574 #define		WILD_F_INHABITED	2
2575 #define		WILD_F_IN_MEMORY	4
2576 
2577 
2578 /*
2579  * Hack -- choose "intelligent" spells when desperate
2580  */
2581 
2582 #define RF4_INT_MASK \
2583    0L
2584 
2585 #define RF5_INT_MASK \
2586   (RF5_HOLD | RF5_SLOW | RF5_CONF | RF5_BLIND | RF5_SCARE)
2587 
2588 #define RF6_INT_MASK \
2589    (RF6_BLINK |  RF6_TPORT | RF6_TELE_LEVEL | RF6_TELE_AWAY | \
2590     RF6_HEAL | RF6_HASTE | RF6_TRAPS | \
2591     RF6_S_MONSTER | RF6_S_MONSTERS | \
2592    	RF6_S_ANIMAL | RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | \
2593     RF6_S_ANGEL | RF6_S_DRAGON | RF6_S_UNDEAD | RF6_S_DEMON | \
2594     RF6_S_HI_DRAGON | RF6_S_HI_UNDEAD | RF6_S_WRAITH | RF6_S_UNIQUE)
2595 
2596 /*
2597  * Artifact activation index
2598  */
2599 #define ACT_ILLUMINATION        0
2600 #define ACT_MAGIC_MAP           1
2601 #define ACT_CLAIRVOYANCE        2
2602 #define ACT_PROT_EVIL           3
2603 #define ACT_DISP_EVIL           4
2604 #define ACT_HEAL1               5
2605 #define ACT_HEAL2               6
2606 #define ACT_CURE_WOUNDS         7
2607 #define ACT_HASTE1              8
2608 #define ACT_HASTE2              9
2609 #define ACT_FIRE1               10
2610 #define ACT_FIRE2               11
2611 #define ACT_FIRE3               12
2612 #define ACT_FROST1              13
2613 #define ACT_FROST2              14
2614 #define ACT_FROST3              15
2615 #define ACT_FROST4              16
2616 #define ACT_FROST5              17
2617 #define ACT_ACID1               18
2618 #define ACT_RECHARGE1           19
2619 #define ACT_SLEEP               20
2620 #define ACT_LIGHTNING_BOLT      21
2621 #define ACT_ELEC2               22
2622 #define ACT_BANISHMENT          23
2623 #define ACT_MASS_BANISHMENT     24
2624 #define ACT_IDENTIFY            25
2625 #define ACT_DRAIN_LIFE1         26
2626 #define ACT_DRAIN_LIFE2         27
2627 #define ACT_BIZZARE             28
2628 #define ACT_STAR_BALL           29
2629 #define ACT_RAGE_BLESS_RESIST   30
2630 #define ACT_PHASE               31
2631 #define ACT_TRAP_DOOR_DEST      32
2632 #define ACT_DETECT              33
2633 #define ACT_RESIST              34
2634 #define ACT_TELEPORT            35
2635 #define ACT_RESTORE_LIFE        36
2636 #define ACT_MISSILE             37
2637 #define ACT_ARROW               38
2638 #define ACT_REM_FEAR_POIS       39
2639 #define ACT_STINKING_CLOUD      40
2640 #define ACT_STONE_TO_MUD        41
2641 #define ACT_TELE_AWAY           42
2642 #define ACT_WOR                 43
2643 #define ACT_CONFUSE             44
2644 #define ACT_PROBE               45
2645 #define ACT_FIREBRAND           46
2646 #define ACT_STARLIGHT           47
2647 #define ACT_MANA_BOLT           48
2648 #define ACT_BERSERKER           49
2649 
2650 #define ACT_MAX                 50
2651 
2652 /* Login constants */
2653 #define BAD_PASSWORD 35
2654 
2655 
2656 /*** Macro Definitions ***/
2657 
2658 
2659 /*
2660  * Determine if a given inventory item is "aware"
2661  */
2662 #define object_aware_p(PLR, T) \
2663     ((PLR)->kind_aware[(T)->k_idx])
2664 
2665 /*
2666  * Determine if a given inventory item is "tried"
2667  */
2668 #define object_tried_p(PLR, T) \
2669     ((PLR)->kind_tried[(T)->k_idx])
2670 
2671 /*
2672  * Determine if a given inventory item is "known"
2673  * Test One -- Check for special "known" tag
2674  * Test Two -- Check for "Easy Know" + "Aware"
2675  */
2676 #define object_known_p(PTR, T) \
2677 	(((T)->ident & (ID_KNOWN)) || \
2678 	 ((k_info[(T)->k_idx].flags3 & (TR3_EASY_KNOW)) && \
2679 	  (PTR)->kind_aware[(T)->k_idx]))
2680 
2681 
2682 #define object_felt_or_known_p(IND, T) \
2683     (((T)->ident & ID_SENSE) || \
2684     object_known_p(IND, T))
2685 
2686 /*
2687  * Return the "attr" for a given item.
2688  * Allow user redefinition of "aware" items.
2689  * Default to the "flavor" attr for unaware items
2690  */
2691 #define object_attr_p(PLR, T) \
2692     (object_kind_attr_p((PLR), (T)->k_idx))
2693 
2694 /*
2695  * Return the "char" for a given item.
2696  * Allow user redefinition of "aware" items.
2697  * Default to the "flavor" char for unaware items
2698  */
2699 #define object_char_p(PLR, T) \
2700     (object_kind_char_p((PLR), (T)->k_idx))
2701 
2702 /*
2703  * Return the "attr" for a given object kind.
2704  * Allow user redefinition of "aware" items.
2705  * Default to the "flavor" attr for unaware items.
2706  */
2707 #define object_kind_attr_p(PLR, K_IDX) \
2708     (((PLR)->kind_aware[(K_IDX)]) ? \
2709      ((PLR)->k_attr[(K_IDX)]) : \
2710      ((PLR)->d_attr[(K_IDX)]))
2711 
2712 /*
2713  * Return the "char" for a given object kind.
2714  * Allow user redefinition of "aware" items.
2715  * Default to the "flavor" char for unaware items.
2716  */
2717 #define object_kind_char_p(PLR, K_IDX) \
2718     (((PLR)->kind_aware[(K_IDX)]) ? \
2719      ((PLR)->k_char[(K_IDX)]) : \
2720      ((PLR)->d_char[(K_IDX)]))
2721 
2722 /* Server-side versions of the above macros.
2723  * The difference, is that while those *will* take
2724  * player's awareness of a given object into account,
2725  * they will completely ignore player-side visual mappings */
2726 
2727 #define object_attr_s(PLR, T) \
2728     (object_kind_attr_s((PLR), (T)->k_idx))
2729 
2730 #define object_char_s(PLR, T) \
2731     (object_kind_char_p((PLR), (T)->k_idx))
2732 
2733 #define object_kind_attr_s(PLR, K_IDX) \
2734     (((PLR)->kind_aware[(K_IDX)]) ? \
2735      (k_attr_s[(K_IDX)]) : \
2736      (flavor_attr_s[ k_info[(K_IDX)].flavor ]))
2737 
2738 #define object_kind_char_s(PLR, K_IDX) \
2739     (((PLR)->kind_aware[(K_IDX)]) ? \
2740      (k_char_s[(K_IDX)]) : \
2741      (flavor_char_s[ k_info[(K_IDX)].flavor ]))
2742 
2743 /* Copy object */
2744 #define object_copy(D,S) COPY((D), (S), object_type);
2745 
2746 
2747 /*
2748  * Artifacts use the "name1" field
2749  */
2750 #define artifact_p(T) \
2751         ((T)->name1 ? TRUE : FALSE)
2752 #define true_artifact_p(T) \
2753 	((T)->name1 ? ((T)->name3 ? FALSE : TRUE) : FALSE)
2754 #define randart_p(T) \
2755 	((T)->name1 == ART_RANDART ? TRUE : FALSE)
2756 
2757 
2758 /* Get pointer to correct artifact structure */
2759 #if defined(RANDART)
2760 #define artifact_ptr(O) \
2761 	((O)->name1 == ART_RANDART ? randart_make((O)) \
2762 	 : &a_info[(O)->name1])
2763 #else
2764 #define artifact_ptr(O) \
2765 	(&a_info[(O)->name1])
2766 #endif
2767 
2768 
2769 /*
2770  * Ego-Items use the "name2" field
2771  */
2772 #define ego_item_p(T) \
2773         ((T)->name2 ? TRUE : FALSE)
2774 
2775 
2776 /*
2777  * Broken items.
2778  */
2779 #define broken_p(T) \
2780         ((T)->ident & ID_BROKEN)
2781 
2782 /*
2783  * Cursed items.
2784  */
2785 #define cursed_p(T) \
2786         ((T)->ident & ID_CURSED)
2787 
2788 
2789 
2790 /*
2791  * Determines if a map location is fully inside the outer walls
2792  */
2793 #define in_bounds(DEPTH,Y,X) \
2794    ((DEPTH ? (((Y) > 0) && ((X) > 0) && ((Y) < MAX_HGT-1) && ((X) < MAX_WID-1)) \
2795            : (((Y) > 0) && ((X) > 0) && ((Y) < MAX_HGT-1) && ((X) < MAX_WID-1))))
2796 
2797 /*
2798  * Determines if a map location is fully inside the outer walls
2799  * This is more than twice as expensive as "in_bounds()", but
2800  * often we need to exclude the outer walls from calculations.
2801  */
2802 #define in_bounds_fully(Y,X) \
2803 	(((Y) > 0) && ((Y) < MAX_HGT-1) && \
2804 	 ((X) > 0) && ((X) < MAX_WID-1))
2805 
2806 
2807 /*
2808  * Determines if a map location is on or inside the outer walls
2809  */
2810 #define in_bounds2(DEPTH,Y,X) \
2811    ((DEPTH ? (((Y) >= 0) && ((X) >= 0) && ((Y) < MAX_HGT) && ((X) < MAX_WID)) \
2812       : (((Y) > 0) && ((X) > 0) && ((Y) < MAX_HGT) && ((X) < MAX_WID))))
2813 
2814 
2815 /*
2816  * Determines if a map location is currently "on screen" -RAK-
2817  * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
2818  */
2819 #define panel_contains(P_PTR,Y,X) \
2820   (((Y) >= (P_PTR)->panel_row_min) && ((Y) <= (P_PTR)->panel_row_max) && \
2821    ((X) >= (P_PTR)->panel_col_min) && ((X) <= (P_PTR)->panel_col_max))
2822 
2823 
2824 /*
2825  * Determine if a "legal" grid is a "floor" grid
2826  *
2827  * Line 1 -- forbid doors, rubble, seams, walls
2828  *
2829  * Note that the terrain features are split by a one bit test
2830  * into those features which block line of sight and those that
2831  * do not, allowing an extremely fast single bit check below.
2832  */
2833 #define cave_floor_bold(DEPTH,Y,X) \
2834     (!(cave[DEPTH][Y][X].feat & 0x20))
2835 
2836 /*
2837  * Determine if a grid is an "naked" wilderness grid
2838  * Line 1 -- forbid in dungeon
2839  * Line 2-3 -- forbid non-terrain
2840  */
2841 #define cave_wild_bold(DEPTH,Y,X) \
2842 	(!(DEPTH > 0) && \
2843 	(((cave[DEPTH][Y][X].feat >= FEAT_DIRT) && \
2844 	  (cave[DEPTH][Y][X].feat <= FEAT_LOOSE_DIRT)) || \
2845 	(((cave[DEPTH][Y][X].feat >= FEAT_CROP_HEAD) && \
2846 	  (cave[DEPTH][Y][X].feat <= FEAT_CROP_TAIL)))))
2847 
2848 
2849 /*
2850  * Determine if a "legal" grid is a "clean" floor grid
2851  *
2852  * Line 1 -- forbid non-floors
2853  * Line 2 -- forbid non-terrain
2854  * Line 2 -- forbid normal objects
2855  */
2856 #define cave_clean_bold(DEPTH,Y,X) \
2857    (((cave[DEPTH][Y][X].feat == FEAT_FLOOR) || \
2858      (cave_wild_bold(DEPTH,Y,X))) && \
2859     (!cave[DEPTH][Y][X].o_idx))
2860 
2861 /*
2862  * Determine if a "legal" grid is an "empty" floor grid
2863  *
2864  * Line 1 -- forbid doors, rubble, seams, walls
2865  * Line 2 -- forbid normal monsters
2866  * Line 3 -- forbid any player
2867  */
2868 #define cave_empty_bold(DEPTH,Y,X) \
2869     (cave_floor_bold(DEPTH,Y,X) && \
2870      !(cave[DEPTH][Y][X].m_idx))
2871 
2872 /*
2873  * Determine if a "legal" grid is an "naked" floor grid
2874  *
2875  * Line 1 -- forbid non-wild floors
2876  * Line 2 -- forbid non-floors
2877  * Line 3 -- forbid normal objects
2878  * Line 4 -- forbid normal monsters
2879  * Line 5 -- forbid any player... MISSING ?
2880  */
2881 #define cave_naked_bold(DEPTH,Y,X) \
2882 	(((cave_wild_bold(DEPTH,Y,X))	|| \
2883 	  (cave[DEPTH][Y][X].feat == FEAT_FLOOR)) && \
2884 	!(cave[DEPTH][Y][X].o_idx) && \
2885 	!(cave[DEPTH][Y][X].m_idx))
2886 
2887 
2888 /*
2889  * Determine if a "legal" grid is "permanent"
2890  *
2891  * Line 1 -- perma-walls in town
2892  * Line 2-3 -- perma-walls
2893  * Line 4-5 -- stairs
2894  * Line 6-7 -- shop doors
2895  * Lines 8-9 -- home doors
2896  */
2897 #define cave_perma_bold(DEPTH,Y,X) \
2898     ((cave[DEPTH][Y][X].feat == FEAT_PERM_CLEAR) || \
2899     ((cave[DEPTH][Y][X].feat >= FEAT_PERM_EXTRA) && \
2900       (cave[DEPTH][Y][X].feat <= FEAT_PERM_SOLID)) || \
2901      ((cave[DEPTH][Y][X].feat == FEAT_LESS) || \
2902       (cave[DEPTH][Y][X].feat == FEAT_MORE)) || \
2903      ((cave[DEPTH][Y][X].feat >= FEAT_SHOP_HEAD) && \
2904       (cave[DEPTH][Y][X].feat <= FEAT_SHOP_TAIL)) || \
2905      ((cave[DEPTH][Y][X].feat >= FEAT_HOME_HEAD) && \
2906       (cave[DEPTH][Y][X].feat <= FEAT_HOME_TAIL)))
2907 
2908 /*
2909  * Is a given location "valid" for placing things?
2910  *
2911  * Permanent grids are never "valid" (see above).
2912  *
2913  * Hack -- a grid with an artifact in it is never valid.
2914  *
2915  * This function is often "combined" with "cave_floor_bold(Y,X)"
2916  * or one of the other similar macros above.
2917  *
2918  * Line 1 -- forbid perma-grids
2919  * Line 2-3 -- forbid grids containing artifacts
2920  * Line 4 -- forbit house doors
2921  */
2922 #define cave_valid_bold(DEPTH,Y,X) \
2923     (!cave_perma_bold(DEPTH,Y,X) && \
2924      (!cave[DEPTH][Y][X].o_idx || \
2925       !artifact_p(&o_list[cave[DEPTH][Y][X].o_idx])))
2926 
2927 
2928 
2929 /*
2930  * Grid based version of "cave_floor_bold()"
2931  */
2932 #define cave_floor_grid(C) \
2933     (!((C)->feat & 0x20))
2934 
2935 
2936 /*
2937  * Grid based version of "cave_wild_bold()"
2938  */
2939 #define cave_wild_grid(C) \
2940 	(((C)->feat >= FEAT_DIRT) && \
2941 	 ((C)->feat <= FEAT_LOOSE_DIRT))
2942 
2943 
2944 /*
2945  * Grid based version of "cave_clean_bold()"
2946  */
2947 #define cave_clean_grid(C) \
2948     (((C)->feat == FEAT_FLOOR) || \
2949      (cave_wild_grid(C)) && \
2950      (!(C)->o_idx))
2951 
2952 /*
2953  * Grid based version of "cave_empty_bold()"
2954  */
2955 #define cave_empty_grid(C) \
2956     (cave_floor_grid(C) && \
2957      !((C)->m_idx))
2958 
2959 /*
2960  * Grid based version of "cave_empty_bold()"
2961  */
2962 #define cave_naked_grid(C) \
2963     ((((C)->feat == FEAT_FLOOR) || \
2964      		cave_wild_grid(C)) && \
2965      !((C)->o_idx) && \
2966      			!((C)->m_idx)))
2967 
2968 /*
2969  * Grid based version of "cave_perma_bold()"
2970  */
2971 #define cave_perma_grid(C) \
2972     (((C)->feat >= FEAT_PERM_EXTRA) || \
2973      (((C)->feat == FEAT_LESS) || \
2974       ((C)->feat == FEAT_MORE)) || \
2975      (((C)->feat >= FEAT_SHOP_HEAD) && \
2976       ((C)->feat <= FEAT_SHOP_TAIL)))
2977 
2978 
2979 /*
2980  * Grid based version of "cave_valid_bold()"
2981  */
2982 #define cave_valid_grid(C) \
2983     (!cave_perma_grid(C) && \
2984      (!(C)->o_idx || \
2985       !artifact_p(&o_list[(C)->o_idx])))
2986 
2987 
2988 
2989 /*
2990  * Determine if a "legal" grid is within "los" of the player
2991  *
2992  * Note the use of comparison to zero to force a "boolean" result
2993  */
2994 #define player_has_los_bold(PLR,Y,X) \
2995     ((PLR->cave_flag[Y][X] & CAVE_VIEW) != 0)
2996 
2997 /*
2998  * Convert an "attr"/"char" pair into a "pict" (P)
2999  */
3000 #define PICT(A,C) \
3001 	((((u16b)(A)) << 8) | ((byte)(C)))
3002 
3003 /*
3004  * Convert a "pict" (P) into an "attr" (A)
3005  */
3006 #define PICT_A(P) \
3007 	((byte)((P) >> 8))
3008 
3009 /*
3010  * Convert a "pict" (P) into an "char" (C)
3011  */
3012 #define PICT_C(P) \
3013 	((char)((byte)(P)))
3014 
3015 /*
3016  * Determine if a dungeon level of specific "depth" is a town.
3017  */
3018 #define level_is_town(DEPTH) \
3019 	((DEPTH) == 0 || (cfg_more_towns && check_special_level((DEPTH))))
3020 
3021 
3022 /*
3023  * Get index for a player
3024  */
3025 #define player_index(PLR) ( (PLR)->Ind )
3026 
3027 /*
3028  * Compare two players
3029  */
3030 #define same_player(PLR1, PLR2) ( (PLR1) == (PLR2) )
3031 
3032 /*
3033  * Iterate over all players
3034  * ITER must be a defined "int".
3035  * PLR must be a defined "player_type*".
3036  */
3037 #define foreach_player(ITER, PLR) \
3038 	for (\
3039 		(ITER) = 1;\
3040 		((ITER) <= NumPlayers) && ((PLR) = Players[(ITER)]); \
3041 		(ITER)++ \
3042 	    )
3043 
3044 /* Define iterator to use with "foreach_player" */
3045 #define player_iterator(ITER, PLR) \
3046 	int (ITER); \
3047 	player_type* (PLR);
3048 
3049 /*
3050  * Hack -- Prepare to use the "Secure" routines
3051  */
3052 #if defined(SET_UID) && defined(SECURE)
3053 extern int PlayerUID;
3054 # define getuid() PlayerUID
3055 # define geteuid() PlayerUID
3056 #endif
3057