Source:NetHack 5.0.0/src/monst.c
Jump to navigation
Jump to search
Below is the full text to monst.c from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/src/monst.c#line12]], for example.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* NetHack 5.0 monst.c $NHDT-Date: 1705092160 2024/01/12 20:42:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /*-Copyright (c) Michael Allison, 2006. */ 4. /* NetHack may be freely redistributed. See license for details. */ 5. 6. #include "config.h" 7. #include "weight.h" 8. #include "permonst.h" 9. #include "wintype.h" 10. #include "sym.h" 11. 12. #include "color.h" 13. 14. extern const struct attack c_sa_yes[NATTK]; 15. extern const struct attack c_sa_no[NATTK]; 16. 17. #define NO_ATTK { 0, 0, 0, 0 } 18. 19. /* monster type with single name */ 20. #define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \ 21. flg1, flg2, flg3, d, col, bn) \ 22. { \ 23. nam, PM_##bn, \ 24. sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \ 25. } 26. 27. /* LVL() and SIZ() collect several fields to cut down on number of args 28. * for MON(). Using more than 15 would fail to conform to the C Standard. 29. * ATTK() and A() are to avoid braces and commas within args to MON(). 30. * NAM() and NAMS() are used for both reasons. 31. */ 32. #define NAM(name) { (const char *) 0, (const char *) 0, name } 33. #define NAMS(namm, namf, namn) { namm, namf, namn } 34. #define LVL(lvl, mov, ac, mr, aln) lvl, mov, ac, mr, aln 35. #define SIZ(wt, nut, snd, siz) wt, nut, snd, siz 36. #define ATTK(at, ad, n, d) { at, ad, n, d } 37. #define A(a1, a2, a3, a4, a5, a6) { a1, a2, a3, a4, a5, a6 } 38. 39. static struct permonst mons_init[NUMMONS + 1] = { 40. #include "monsters.h" 41. /* 42. * Array terminator, added to the end of the entries in monsters.h. 43. * 44. * mons[NUMMONS] used to be all zero except "" instead of Null for 45. * the name field. Then the index field was added and the terminator 46. * uses NON_PM for that. Now, a few monster flags also get set. 47. */ 48. #undef MON 49. #define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \ 50. flg1, flg2, flg3, d, col, bn) \ 51. { \ 52. nam, NON_PM, \ 53. sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \ 54. } 55. MON(NAM(""), 0, 56. LVL(0, 0, 0, 0, 0), G_NOGEN | G_NOCORPSE, 57. A(NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), 58. SIZ(0, 0, 0, 0), 0, 0, 59. 0L, M2_NOPOLY, 0, 60. 0, 0, 0), 61. }; 62. 63. #undef MON 64. #undef NAM 65. #undef NAMS 66. 67. void monst_globals_init(void); /* in hack.h but we're using config.h */ 68. 69. struct permonst mons[SIZE(mons_init)]; 70. 71. void 72. monst_globals_init(void) 73. { 74. memcpy(mons, mons_init, sizeof mons); 75. return; 76. } 77. 78. const struct attack c_sa_yes[NATTK] = SEDUCTION_ATTACKS_YES; 79. const struct attack c_sa_no[NATTK] = SEDUCTION_ATTACKS_NO; 80. 81. /* for 'onefile' processing where end of this file isn't necessarily the 82. end of the source code seen by the compiler */ 83. #undef NO_ATTK 84. #undef LVL 85. #undef SIZ 86. #undef ATTK 87. #undef A 88. 89. /*monst.c*/