forked from NetHack/NetHack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhack.h
More file actions
1572 lines (1384 loc) · 55.1 KB
/
hack.h
File metadata and controls
1572 lines (1384 loc) · 55.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* NetHack 3.7 hack.h $NHDT-Date: 1736530208 2025/01/10 09:30:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.266 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2017. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef HACK_H
#define HACK_H
#ifndef CONFIG_H
#include "config.h"
#endif
#include "lint.h"
#include "align.h"
#include "weight.h"
#include "dungeon.h"
#include "stairs.h"
#include "objclass.h"
#include "wintype.h"
#include "flag.h"
#include "rect.h"
#include "sym.h"
#include "trap.h"
#include "youprop.h"
#include "display.h"
#include "botl.h"
#include "context.h"
#include "engrave.h"
#include "mkroom.h"
#include "obj.h"
#include "quest.h"
#include "region.h"
#include "rm.h"
#include "selvar.h"
#include "sndprocs.h"
#include "spell.h"
#include "sys.h"
#include "timeout.h"
#include "winprocs.h"
#include "wintype.h"
#include "vision.h"
#include "you.h"
#define TELL 1
#define NOTELL 0
#define ON 1
#define OFF 0
#define BOLT_LIM 8 /* from this distance ranged attacks will be made */
#define DUMMY { 0 } /* array initializer, letting [1..N-1] default */
#define DEF_NOTHING ' ' /* default symbol for NOTHING and UNEXPLORED */
/* Macros for how a rumor was delivered in outrumor() */
#define BY_ORACLE 0
#define BY_COOKIE 1
#define BY_PAPER 2
#define BY_OTHER 9
/* bitmask flags for corpse_xname();
PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */
#define CXN_NORMAL 0 /* no special handling */
#define CXN_SINGULAR 1 /* override quantity if greater than 1 */
#define CXN_NO_PFX 2 /* suppress "the" from "the Unique Monst */
#define CXN_PFX_THE 4 /* prefix with "the " (unless pname) */
#define CXN_ARTICLE 8 /* include a/an/the prefix */
#define CXN_NOCORPSE 16 /* suppress " corpse" suffix */
/* number of turns it takes for vault guard to show up */
#define VAULT_GUARD_TIME 30
/* sellobj_state() states */
#define SELL_NORMAL (0)
#define SELL_DELIBERATE (1)
#define SELL_DONTSELL (2)
#define SHOP_DOOR_COST 400L /* cost of a destroyed shop door */
#define SHOP_BARS_COST 300L /* cost of iron bars */
#define SHOP_HOLE_COST 200L /* cost of making hole/trapdoor */
#define SHOP_WALL_COST 200L /* cost of destroying a wall */
#define SHOP_WALL_DMG (10L * ACURRSTR) /* damaging a wall */
#define SHOP_PIT_COST 100L /* cost of making a pit */
#define SHOP_WEB_COST 30L /* cost of removing a web */
/* flags for look_here() */
#define LOOKHERE_NOFLAGS 0U
#define LOOKHERE_PICKED_SOME 1U
#define LOOKHERE_SKIP_DFEATURE 2U
/* max size of a windowtype option */
#define WINTYPELEN 16
/* str_or_len from sp_lev.h */
typedef union str_or_len {
char *str;
int len;
} Str_or_Len;
enum artifacts_nums {
#define ARTI_ENUM
#include "artilist.h"
#undef ARTI_ENUM
AFTER_LAST_ARTIFACT
};
enum misc_arti_nums {
NROFARTIFACTS = (AFTER_LAST_ARTIFACT - 1)
};
/* related to breadcrumb struct */
enum bcargs {override_restriction = -1};
struct breadcrumbs {
const char *funcnm;
int linenum;
boolean in_effect;
};
/* types of calls to bhit() */
enum bhit_call_types {
ZAPPED_WAND = 0,
THROWN_WEAPON = 1,
THROWN_TETHERED_WEAPON = 2,
KICKED_WEAPON = 3,
FLASHED_LIGHT = 4,
INVIS_BEAM = 5
};
/* Macros for messages referring to hands, eyes, feet, etc... */
enum bodypart_types {
NO_PART = -1,
ARM = 0,
EYE = 1,
FACE = 2,
FINGER = 3,
FINGERTIP = 4,
FOOT = 5,
HAND = 6,
HANDED = 7,
HEAD = 8,
LEG = 9,
LIGHT_HEADED = 10,
NECK = 11,
SPINE = 12,
TOE = 13,
HAIR = 14,
BLOOD = 15,
LUNG = 16,
NOSE = 17,
STOMACH = 18
};
#define MAX_BMASK 4
struct bubble {
coordxy x, y; /* coordinates of the upper left corner */
schar dx, dy; /* the general direction of the bubble's movement */
uchar bm[MAX_BMASK + 2]; /* bubble bit mask */
struct bubble *prev, *next; /* need to traverse the list up and down */
struct container *cons;
};
enum bubble_contains_types {
CONS_OBJ = 0,
CONS_MON,
CONS_HERO,
CONS_TRAP
};
/*
* Rudimentary command queue.
* Allows the code to put keys and extended commands into the queue,
* and they're executed just as if the user did them. Time passes
* normally when doing queued actions. The queue will get cleared
* if hero is interrupted.
*/
enum cmdq_cmdtypes {
CMDQ_KEY = 0, /* a literal character, cmdq_add_key() */
CMDQ_EXTCMD, /* extended command, cmdq_add_ec() */
CMDQ_DIR, /* direction, cmdq_add_dir() */
CMDQ_USER_INPUT, /* placeholder for user input, cmdq_add_userinput() */
CMDQ_INT, /* integer value, cmdq_add_int() */
};
struct _cmd_queue {
int typ;
char key;
schar dirx, diry, dirz;
int intval;
const struct ext_func_tab *ec_entry;
struct _cmd_queue *next;
};
enum {
CQ_CANNED = 0, /* internal canned sequence */
CQ_REPEAT, /* user-inputted, if gi.in_doagain, replayed */
NUM_CQS
};
typedef long cmdcount_nht; /* Command counts */
/* special key functions */
enum nh_keyfunc {
NHKF_ESC = 0,
NHKF_GETDIR_SELF,
NHKF_GETDIR_SELF2,
NHKF_GETDIR_HELP,
NHKF_GETDIR_MOUSE, /* simulated click for #therecmdmenu; use '_' as
* direction to initiate, then getpos() finishing
* with ',' (left click) or '.' (right click) */
NHKF_COUNT,
NHKF_GETPOS_SELF,
NHKF_GETPOS_PICK,
NHKF_GETPOS_PICK_Q, /* quick */
NHKF_GETPOS_PICK_O, /* once */
NHKF_GETPOS_PICK_V, /* verbose */
NHKF_GETPOS_SHOWVALID,
NHKF_GETPOS_AUTODESC,
NHKF_GETPOS_MON_NEXT,
NHKF_GETPOS_MON_PREV,
NHKF_GETPOS_OBJ_NEXT,
NHKF_GETPOS_OBJ_PREV,
NHKF_GETPOS_DOOR_NEXT,
NHKF_GETPOS_DOOR_PREV,
NHKF_GETPOS_UNEX_NEXT,
NHKF_GETPOS_UNEX_PREV,
NHKF_GETPOS_INTERESTING_NEXT,
NHKF_GETPOS_INTERESTING_PREV,
NHKF_GETPOS_VALID_NEXT,
NHKF_GETPOS_VALID_PREV,
NHKF_GETPOS_HELP,
NHKF_GETPOS_MENU,
NHKF_GETPOS_LIMITVIEW,
NHKF_GETPOS_MOVESKIP,
NUM_NHKF
};
/* commands[] is used to directly access cmdlist[] instead of looping
through it to find the entry for a given input character;
move_X is the character used for moving one step in direction X;
alphadirchars corresponds to old sdir,
dirchars corresponds to ``iflags.num_pad ? ndir : sdir'';
pcHack_compat and phone_layout only matter when num_pad is on,
swap_yz only matters when it's off */
struct cmd {
unsigned serialno; /* incremented after each update */
boolean num_pad; /* same as iflags.num_pad except during updates */
boolean pcHack_compat; /* for numpad: affects 5, M-5, and M-0 */
boolean phone_layout; /* inverted keypad: 1,2,3 above, 7,8,9 below */
boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */
const char *dirchars; /* current movement/direction characters */
const char *alphadirchars; /* same as dirchars if !numpad */
const struct ext_func_tab *commands[256]; /* indexed by input character */
const struct ext_func_tab *mousebtn[NUM_MOUSE_BUTTONS];
char spkeys[NUM_NHKF];
char extcmd_char; /* key that starts an extended command ('#') */
};
struct c_color_names {
const char *const c_black, *const c_amber, *const c_golden,
*const c_light_blue, *const c_red, *const c_green, *const c_silver,
*const c_blue, *const c_purple, *const c_white, *const c_orange;
};
struct c_common_strings {
const char *const c_nothing_happens, *const c_nothing_seems_to_happen,
*const c_thats_enough_tries, *const c_silly_thing_to,
*const c_shudder_for_moment, *const c_something, *const c_Something,
*const c_You_can_move_again, *const c_Never_mind,
*const c_vision_clears, *const c_the_your[2], *const c_fakename[2];
};
struct container {
struct container *next;
coordxy x, y;
short what;
genericptr_t list;
};
/* alteration types--keep in synch with costly_alteration(mkobj.c) */
enum cost_alteration_types {
COST_CANCEL = 0, /* standard cancellation */
COST_DRAIN = 1, /* drain life upon an object */
COST_UNCHRG = 2, /* cursed charging */
COST_UNBLSS = 3, /* unbless (devalues holy water) */
COST_UNCURS = 4, /* uncurse (devalues unholy water) */
COST_DECHNT = 5, /* disenchant weapons or armor */
COST_DEGRD = 6, /* removal of rustproofing, dulling via engraving */
COST_DILUTE = 7, /* potion dilution */
COST_ERASE = 8, /* scroll or spellbook blanking */
COST_BURN = 9, /* dipped into flaming oil */
COST_NUTRLZ = 10, /* neutralized via unicorn horn */
COST_DSTROY = 11, /* wand breaking (bill first, useup later) */
COST_SPLAT = 12, /* cream pie to own face (ditto) */
COST_BITE = 13, /* start eating food */
COST_OPEN = 14, /* open tin */
COST_BRKLCK = 15, /* break box/chest's lock */
COST_RUST = 16, /* rust damage */
COST_ROT = 17, /* rotting attack */
COST_CORRODE = 18, /* acid damage */
COST_CRACK = 19, /* damage to crystal armor */
};
/* used by unpaid_cost(shk.h) */
enum unpaid_cost_flags {
COST_NOCONTENTS = 0,
COST_CONTENTS = 1,
COST_SINGLEOBJ = 2,
};
/* read.c, create_particular() & create_particular_parse() */
struct _create_particular_data {
int quan;
int which;
int fem; /* -1, MALE, FEMALE, NEUTRAL */
int genderconf; /* conflicting gender */
char monclass;
boolean randmonst;
boolean maketame, makepeaceful, makehostile;
boolean sleeping, saddled, invisible, hidden;
};
/* dig_check() results */
enum digcheck_result {
DIGCHECK_PASSED = 1,
DIGCHECK_PASSED_DESTROY_TRAP = 2,
DIGCHECK_PASSED_PITONLY = 3,
DIGCHECK_FAILED = 4,
DIGCHECK_FAIL_ONSTAIRS = DIGCHECK_FAILED,
DIGCHECK_FAIL_ONLADDER,
DIGCHECK_FAIL_THRONE,
DIGCHECK_FAIL_ALTAR,
DIGCHECK_FAIL_AIRLEVEL,
DIGCHECK_FAIL_WATERLEVEL,
DIGCHECK_FAIL_TOOHARD,
DIGCHECK_FAIL_UNDESTROYABLETRAP,
DIGCHECK_FAIL_CANTDIG,
DIGCHECK_FAIL_BOULDER,
DIGCHECK_FAIL_OBJ_POOL_OR_TRAP
};
/* Dismount: causes for why you are no longer riding */
enum dismount_types {
DISMOUNT_GENERIC = 0,
DISMOUNT_FELL = 1,
DISMOUNT_THROWN = 2,
DISMOUNT_KNOCKED = 3, /* hero hit for knockback effect */
DISMOUNT_POLY = 4,
DISMOUNT_ENGULFED = 5,
DISMOUNT_BONES = 6,
DISMOUNT_BYCHOICE = 7
};
struct dgn_topology { /* special dungeon levels for speed */
d_level d_oracle_level;
d_level d_bigroom_level; /* unused */
d_level d_rogue_level;
d_level d_medusa_level;
d_level d_stronghold_level;
d_level d_valley_level;
d_level d_wiz1_level;
d_level d_wiz2_level;
d_level d_wiz3_level;
d_level d_juiblex_level;
d_level d_orcus_level;
d_level d_baalzebub_level; /* unused */
d_level d_asmodeus_level; /* unused */
d_level d_portal_level; /* only in goto_level() [do.c] */
d_level d_sanctum_level;
d_level d_earth_level;
d_level d_water_level;
d_level d_fire_level;
d_level d_air_level;
d_level d_astral_level;
xint16 d_tower_dnum;
xint16 d_sokoban_dnum;
xint16 d_mines_dnum, d_quest_dnum;
xint16 d_tutorial_dnum;
d_level d_qstart_level, d_qlocate_level, d_nemesis_level;
d_level d_knox_level;
d_level d_mineend_level;
d_level d_sokoend_level;
};
/* macros for accessing the dungeon levels by their old names */
/* clang-format off */
#define oracle_level (svd.dungeon_topology.d_oracle_level)
#define bigroom_level (svd.dungeon_topology.d_bigroom_level)
#define rogue_level (svd.dungeon_topology.d_rogue_level)
#define medusa_level (svd.dungeon_topology.d_medusa_level)
#define stronghold_level (svd.dungeon_topology.d_stronghold_level)
#define valley_level (svd.dungeon_topology.d_valley_level)
#define wiz1_level (svd.dungeon_topology.d_wiz1_level)
#define wiz2_level (svd.dungeon_topology.d_wiz2_level)
#define wiz3_level (svd.dungeon_topology.d_wiz3_level)
#define juiblex_level (svd.dungeon_topology.d_juiblex_level)
#define orcus_level (svd.dungeon_topology.d_orcus_level)
#define baalzebub_level (svd.dungeon_topology.d_baalzebub_level)
#define asmodeus_level (svd.dungeon_topology.d_asmodeus_level)
#define portal_level (svd.dungeon_topology.d_portal_level)
#define sanctum_level (svd.dungeon_topology.d_sanctum_level)
#define earth_level (svd.dungeon_topology.d_earth_level)
#define water_level (svd.dungeon_topology.d_water_level)
#define fire_level (svd.dungeon_topology.d_fire_level)
#define air_level (svd.dungeon_topology.d_air_level)
#define astral_level (svd.dungeon_topology.d_astral_level)
#define tower_dnum (svd.dungeon_topology.d_tower_dnum)
#define sokoban_dnum (svd.dungeon_topology.d_sokoban_dnum)
#define mines_dnum (svd.dungeon_topology.d_mines_dnum)
#define quest_dnum (svd.dungeon_topology.d_quest_dnum)
#define tutorial_dnum (svd.dungeon_topology.d_tutorial_dnum)
#define qstart_level (svd.dungeon_topology.d_qstart_level)
#define qlocate_level (svd.dungeon_topology.d_qlocate_level)
#define nemesis_level (svd.dungeon_topology.d_nemesis_level)
#define knox_level (svd.dungeon_topology.d_knox_level)
#define mineend_level (svd.dungeon_topology.d_mineend_level)
#define sokoend_level (svd.dungeon_topology.d_sokoend_level)
/* clang-format on */
#define dunlev_reached(x) (svd.dungeons[(x)->dnum].dunlev_ureached)
#define MAXLINFO (MAXDUNGEON * MAXLEVEL)
enum lua_theme_group {
all_themes = 1, /* for end of game */
most_themes = 2, /* for entering endgame */
tut_themes = 3, /* for leaving tutorial */
};
enum earlyarg {
ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS
#ifndef NODUMPENUMS
, ARG_DUMPENUMS
#endif
, ARG_DUMPGLYPHIDS
, ARG_DUMPMONGEN
, ARG_DUMPWEIGHTS
#ifdef WIN32
, ARG_WINDOWS
#endif
#if defined(CRASHREPORT)
, ARG_BIDSHOW
#endif
};
struct early_opt {
enum earlyarg e;
const char *name;
int minlength;
boolean valallowed;
};
/* symbolic names for capacity levels */
enum encumbrance_types {
UNENCUMBERED = 0,
SLT_ENCUMBER = 1, /* Burdened */
MOD_ENCUMBER = 2, /* Stressed */
HVY_ENCUMBER = 3, /* Strained */
EXT_ENCUMBER = 4, /* Overtaxed */
OVERLOADED = 5 /* Overloaded */
};
struct entity {
struct monst *emon; /* youmonst for the player */
struct permonst *edata; /* must be non-zero for record to be valid */
int ex, ey;
};
struct enum_dump {
int val;
const char *nm;
};
/*
* This is the way the game ends. If these are rearranged, the arrays
* in end.c and topten.c will need to be changed. Some parts of the
* code assume that PANICKED separates the deaths from the non-deaths.
*/
enum game_end_types {
DIED = 0,
CHOKING = 1,
POISONING = 2,
STARVING = 3,
DROWNING = 4,
BURNING = 5,
DISSOLVED = 6,
CRUSHING = 7,
STONING = 8,
TURNED_SLIME = 9,
GENOCIDED = 10,
PANICKED = 11,
TRICKED = 12,
QUIT = 13,
ESCAPED = 14,
ASCENDED = 15
};
/* game events log */
struct gamelog_line {
long turn; /* turn when this happened */
long flags; /* LL_foo flags */
char *text;
struct gamelog_line *next;
};
/* values returned from getobj() callback functions */
enum getobj_callback_returns {
/* generally invalid - can't be used for this purpose. will give a "silly
* thing" message if the player tries to pick it, unless a more specific
* failure message is in getobj itself - e.g. "You cannot foo gold". */
GETOBJ_EXCLUDE = -3,
/* invalid because it is not in inventory; used when the hands/self
* possibility is queried and the player passed up something on the
* floor before getobj. */
GETOBJ_EXCLUDE_NONINVENT = -2,
/* invalid because it is an inaccessible or unwanted piece of gear, but
* pseudo-valid for the purposes of allowing the player to select it and
* getobj to return it if there is a prompt instead of getting "silly
* thing", in order for the getobj caller to present a specific failure
* message. Other than that, the only thing this does differently from
* GETOBJ_EXCLUDE is that it inserts an "else" in "You don't have anything
* else to foo". */
GETOBJ_EXCLUDE_INACCESS = -1,
/* invalid for purposes of not showing a prompt if nothing is valid but
* pseudo-valid for selecting - identical to GETOBJ_EXCLUDE_INACCESS but
* without the "else" in "You don't have anything else to foo". */
GETOBJ_EXCLUDE_SELECTABLE = 0,
/* valid - invlet not presented in the summary or the ? menu as a
* recommendation, but is selectable if the player enters it anyway.
* Used for objects that are actually valid but unimportantly so, such
* as shirts for reading. */
GETOBJ_DOWNPLAY = 1,
/* valid - will be shown in summary and ? menu */
GETOBJ_SUGGEST = 2,
};
/* getpos() return values */
enum getpos_retval {
LOOK_TRADITIONAL = 0, /* '.' -- ask about "more info?" */
LOOK_QUICK = 1, /* ',' -- skip "more info?" */
LOOK_ONCE = 2, /* ';' -- skip and stop looping */
LOOK_VERBOSE = 3 /* ':' -- show more info w/o asking */
};
struct h2o_ctx {
int dkn_boom, unk_boom; /* track dknown, !dknown separately */
boolean ctx_valid;
};
/* attack mode for hmon() */
enum hmon_atkmode_types {
HMON_MELEE = 0, /* hand-to-hand */
HMON_THROWN = 1, /* normal ranged (or spitting while poly'd) */
HMON_KICKED = 2, /* alternate ranged */
HMON_APPLIED = 3, /* polearm, treated as ranged */
HMON_DRAGGED = 4 /* attached iron ball, pulled into mon */
};
/* hunger states - see hu_stat in eat.c */
enum hunger_state_types {
SATIATED = 0,
NOT_HUNGRY = 1,
HUNGRY = 2,
WEAK = 3,
FAINTING = 4,
FAINTED = 5,
STARVED = 6
};
/* inventory counts (slots in tty parlance)
* a...zA..Z invlet_basic (52)
* $a...zA..Z# 2 special additions
*/
enum inventory_counts {
invlet_basic = 52,
invlet_gold = 1,
invlet_overflow = 1,
invlet_max = invlet_basic + invlet_gold + invlet_overflow,
/* 2023/11/30 invlet_max is not yet used anywhere */
};
struct kinfo {
struct kinfo *next; /* chain of delayed killers */
int id; /* uprop keys to ID a delayed killer */
int format; /* one of the killer formats */
#define KILLED_BY_AN 0
#define KILLED_BY 1
#define NO_KILLER_PREFIX 2
char name[BUFSZ]; /* actual killer name */
};
struct launchplace {
struct obj *obj;
coordxy x, y;
};
/* light source */
typedef struct ls_t {
struct ls_t *next;
coordxy x, y; /* source's position */
short range; /* source's current range */
short flags;
short type; /* type of light source */
anything id; /* source's identifier */
} light_source;
struct menucoloring {
struct nhregex *match;
char *origstr;
int color, attr;
struct menucoloring *next;
};
enum movemodes {
MV_ANY = -1,
MV_WALK,
MV_RUN,
MV_RUSH,
N_MOVEMODES
};
enum movementdirs {
DIR_ERR = -1,
DIR_W,
DIR_NW,
DIR_N,
DIR_NE,
DIR_E,
DIR_SE,
DIR_S,
DIR_SW,
DIR_DOWN,
DIR_UP,
N_DIRS_Z
};
/* N_DIRS_Z, minus up & down */
#define N_DIRS (N_DIRS_Z - 2)
/* direction adjustments */
#define DIR_180(dir) (((dir) + 4) % N_DIRS)
#define DIR_LEFT(dir) (((dir) + 7) % N_DIRS)
#define DIR_RIGHT(dir) (((dir) + 1) % N_DIRS)
#define DIR_LEFT2(dir) (((dir) + 6) % N_DIRS)
#define DIR_RIGHT2(dir) (((dir) + 2) % N_DIRS)
#define DIR_CLAMP(dir) (((dir) + N_DIRS) % N_DIRS)
struct multishot {
int n, i;
short o;
boolean s;
};
struct musable {
struct obj *offensive;
struct obj *defensive;
struct obj *misc;
int has_offense, has_defense, has_misc;
/* =0, no capability; otherwise, different numbers.
* If it's an object, the object is also set (it's 0 otherwise).
*/
};
struct mvitals {
uchar born;
uchar died;
uchar mvflags;
Bitfield(seen_close, 1);
Bitfield(photographed, 1);
};
/* Lua callback functions */
enum nhcore_calls {
NHCORE_START_NEW_GAME = 0,
NHCORE_RESTORE_OLD_GAME,
NHCORE_MOVELOOP_TURN,
NHCORE_GAME_EXIT,
NHCORE_GETPOS_TIP,
NHCORE_ENTER_TUTORIAL,
NHCORE_LEAVE_TUTORIAL,
NUM_NHCORE_CALLS
};
/* Lua callbacks. TODO: Merge with NHCORE */
enum nhcb_calls {
NHCB_CMD_BEFORE = 0,
NHCB_LVL_ENTER,
NHCB_LVL_LEAVE,
NHCB_END_TURN,
NUM_NHCB
};
/*
* option setting restrictions
*/
enum optset_restrictions {
set_in_sysconf = 0, /* system config file option only */
set_in_config = 1, /* config file option only */
set_viaprog = 2, /* may be set via extern program, not seen in game */
set_gameview = 3, /* may be set via extern program, displayed in game */
set_in_game = 4, /* may be set via extern program or set in the game */
set_wizonly = 5, /* may be set in the game if wizmode */
set_wiznofuz = 6, /* wizard-mode only, but not by fuzzer */
set_hidden = 7 /* placeholder for prefixed entries, never show it */
};
#define SET__IS_VALUE_VALID(s) ((s < set_in_sysconf) || (s > set_wiznofuz))
struct plinemsg_type {
xint16 msgtype; /* one of MSGTYP_foo */
struct nhregex *regex;
char *pattern;
struct plinemsg_type *next;
};
#define MSGTYP_NORMAL 0
#define MSGTYP_NOREP 1
#define MSGTYP_NOSHOW 2
#define MSGTYP_STOP 3
/* bitmask for callers of hide_unhide_msgtypes() */
#define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW))
/* polyself flags */
enum polyself_flags {
POLY_NOFLAGS = 0x00,
POLY_CONTROLLED = 0x01,
POLY_MONSTER = 0x02,
POLY_REVERT = 0x04,
POLY_LOW_CTRL = 0x08
};
struct repo { /* repossession context */
struct monst *shopkeeper;
coord location;
};
struct restore_info {
const char *name;
int mread_flags;
};
enum restore_stages {
REST_GSTATE = 1, /* restoring game state + first pass of current level */
REST_LEVELS = 2, /* restoring remainder of dungeon */
REST_CURRENT_LEVEL = 3, /* final pass of restoring current level */
};
struct rogueroom {
coordxy rlx, rly;
coordxy dx, dy;
boolean real;
uchar doortable;
int nroom; /* Only meaningful for "real" rooms */
};
#define NUM_ROLES (13)
struct role_filter {
boolean roles[NUM_ROLES + 1];
short mask;
};
#define NUM_RACES (5)
struct selectionvar {
int wid, hei;
boolean bounds_dirty;
NhRect bounds; /* use selection_getbounds() */
char *map;
};
/* structure for 'program_state'; not saved and restored */
struct sinfo {
int gameover; /* self explanatory? */
int stopprint; /* inhibit further end of game disclosure */
#ifdef HANGUPHANDLING
volatile int done_hup; /* SIGHUP or moral equivalent received
* -- no more screen output */
int preserve_locks; /* don't remove level files prior to exit */
#endif
int something_worth_saving; /* in case of panic */
int panicking; /* `panic' is in progress */
int exiting; /* an exit handler is executing */
int saving; /* creating a save file */
int restoring; /* reloading a save file */
int freeingdata; /* in saveobjchn(), mode FREEING */
int in_getlev; /* in getlev() */
int in_moveloop; /* normal gameplay in progress */
int in_impossible; /* reporting a warning */
int in_docrt; /* in docrt(): redrawing the whole screen */
int in_self_recover; /* processing orphaned level files */
int in_checkpoint; /* saving insurance checkpoint */
int in_parseoptions; /* in parseoptions */
int in_role_selection; /* role/race/&c selection menus in progress */
int in_getlin; /* inside interface getlin routine */
int in_sanity_check; /* for impossible() during sanity checking */
int config_error_ready; /* config_error_add is ready, available */
int beyond_savefile_load; /* set when past savefile loading */
int savefile_completed; /* savefile has completed writing */
#ifdef PANICLOG
int in_paniclog; /* writing a panicloc entry */
#endif
int wizkit_wishing; /* starting wizard mode game w/ WIZKIT file */
/* input_state: used in the core for the 'altmeta' option to process ESC;
used in the curses interface to avoid arrow keys when user is doing
something other than entering a command or direction and in the Qt
interface to suppress menu commands in similar conditions;
readchar() always resets it to 'otherInp' prior to returning */
int input_state; /* whether next key pressed will be entering a command */
#ifdef TTY_GRAPHICS
/* resize_pending only matters when handling a SIGWINCH signal for tty;
getting_char is used along with that and also separately for UNIX;
we minimize #if conditionals for them to avoid unnecessary clutter */
volatile int resize_pending; /* set by signal handler */
volatile int getting_char; /* referenced during signal handling */
#endif
};
/* value of program_state.input_state, significant during readchar();
get_count() expects digits then a command so sets it to commandInp */
enum InputState {
otherInp = 0, /* 'other' */
commandInp = 1, /* readchar() */
getposInp = 2, /* getpos() */
getdirInp = 3, /* getdir() */
};
/* sortloot() return type; needed before extern.h */
struct sortloot_item {
struct obj *obj;
char *str; /* result of loot_xname(obj) in some cases, otherwise null */
/* these need to be signed; 'indx' should be big enough to hold a count
of the largest pile of items, the others fit within char */
int indx; /* index into original list (used as tie-breaker) */
int8 orderclass; /* order rather than object class; 0 => not yet init'd */
int8 subclass; /* subclass for some classes */
int8 disco; /* discovery status */
int8 inuse; /* 0: not in-use or not sorting by inuse_only;
* 1: lit candle/lamp or attached leash; 2: worn armor;
* 3: wielded weapon (including uswapwep and uquiver);
* 4: worn accessory (amulet, rings, blindfold). */
};
typedef struct sortloot_item Loot;
typedef struct strbuf {
int len;
char *str;
char buf[256];
} strbuf_t;
enum stoning_checks {
st_gloves = 0x1, /* wearing gloves? */
st_corpse = 0x2, /* is it a corpse obj? */
st_petrifies = 0x4, /* does the corpse petrify on touch? */
st_resists = 0x8, /* do you have stoning resistance? */
st_all = (st_gloves | st_corpse | st_petrifies | st_resists)
};
struct throw_and_return_weapon {
short otyp;
int range;
Bitfield(tethered, 1);
};
struct trapinfo {
struct obj *tobj;
coordxy tx, ty;
int time_needed;
boolean force_bungle;
};
/* values for rtype are defined in dungeon.h */
/* lev_region from sp_lev.h */
typedef struct {
struct {
coordxy x1, y1, x2, y2;
} inarea;
struct {
coordxy x1, y1, x2, y2;
} delarea;
boolean in_islev, del_islev;
coordxy rtype, padding;
Str_or_Len rname;
} lev_region;
/* Flags for controlling uptodate */
#define UTD_CHECKSIZES 0x01
#define UTD_CHECKFIELDCOUNTS 0x02
#define UTD_SKIP_SANITY1 0x04
#define UTD_SKIP_SAVEFILEINFO 0x08
#define UTD_WITHOUT_WAITSYNCH_PERFILE 0x10
#define UTD_QUIETLY 0x20
/* Values for savefile status */
#define SF_UPTODATE 0
#define SF_OUTDATED 1
#define SF_CRITICAL_BYTE_COUNT_MISMATCH 2
#define SF_DM_IL32LLP64_ON_ILP32LL64 3 /* Wind x64 savefile on x86 */
#define SF_DM_I32LP64_ON_ILP32LL64 4 /* Unix 64 savefile on x86 */
#define SF_DM_ILP32LL64_ON_I32LP64 5 /* x86 savefile on Unix 64 */
#define SF_DM_ILP32LL64_ON_IL32LLP64 6 /* x86 savefile on Wind x64 */
#define SF_DM_I32LP64_ON_IL32LLP64 7 /* Unix 64 savefile on Wind x64 */
#define SF_DM_IL32LLP64_ON_I32LP64 8 /* Wind x64 savefile on Unix 64 */
#define SF_DM_MISMATCH 9 /* generic savefile byte mismatch */
#define ENTITIES 2
struct valuable_data {
long count;
int typ;
};
struct val_list {
struct valuable_data *list;
int size;
};
enum vanq_order_modes {
VANQ_MLVL_MNDX = 0, /* t - traditional: by monster level */
VANQ_MSTR_MNDX, /* d - by difficulty rating */
VANQ_ALPHA_SEP, /* a - alphabetical, first uniques, then ordinary */
VANQ_ALPHA_MIX, /* A - alpha with uniques and ordinary intermixed */
VANQ_MCLS_HTOL, /* C - by class, high to low within class */
VANQ_MCLS_LTOH, /* c - by class, low to high within class */
VANQ_COUNT_H_L, /* n - by count, high to low */
VANQ_COUNT_L_H, /* z - by count, low to high */
NUM_VANQ_ORDER_MODES
};
struct autopickup_exception {
struct nhregex *regex;
char *pattern;
boolean grab;
struct autopickup_exception *next;
};
/* at most one of `door' and `box' should be non-null at any given time */
struct xlock_s {
struct rm *door;
struct obj *box;
int picktyp, /* key|pick|card for unlock, sharp vs blunt for #force */
chance, usedtime;
boolean magic_key;
};
#define MAX_BMASK 4
/* NetHack ftypes */
#define NHF_LEVELFILE 1
#define NHF_SAVEFILE 2
#define NHF_BONESFILE 3
/* modes */
#define READING 0x0
#define COUNTING 0x01
#define WRITING 0x02
#define FREEING 0x04
#define CONVERTING 0x08
#define UNCONVERTING 0x10
#if 0
/* operations of the various saveXXXchn & co. routines */
#define perform_bwrite(nhfp) ((nhfp)->mode & (COUNTING | WRITING))
#define release_data(nhfp) ((nhfp)->mode & FREEING)
#endif
/* operations of the various saveXXXchn & co. routines */
#define update_file(nhfp) ((nhfp)->mode & (COUNTING | WRITING))
#define release_data(nhfp) ((nhfp)->mode & FREEING)
enum saveformats {
invalid = 0,
historical = 1, /* entire struct, binary, as-is */
exportascii = 2, /* each field written out as ascii text */
NUM_SAVEFORMATS
};
/* Content types for fieldlevel files */
struct fieldlevel_content {
boolean deflt; /* individual fields */
boolean binary; /* binary rather than text */
};
struct nh_file {
int fd; /* for traditional structlevel binary writes */
int mode; /* holds READING, WRITING, FREEING, CONVERTING modes */
int ftype; /* NHF_LEVELFILE, NHF_SAVEFILE, or NHF_BONESFILE */
int fnidx; /* index of procs for fieldlevel saves */
long rcount, /* read count since opening */
wcount; /* write count since opening */
boolean structlevel; /* traditional structure binary saves */
boolean fieldlevel; /* fieldlevel saves each field individually */
boolean addinfo; /* if set, some additional context info from core */
boolean eof; /* place to mark eof reached */
boolean bendian; /* set to true if executing on big-endian machine */
FILE *fpdef; /* file pointer for fieldlevel default style */
FILE *fpdefmap; /* file pointer mapfile for def format */