monster.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. /* =============================================================================
  2. * PROGRAM: ularn
  3. * FILENAME: monster.h
  4. *
  5. * DESCRIPTION:
  6. * This module handles most aspects of monsters in the game.
  7. * It provides the monster definitions.
  8. * Handles monster creation.
  9. * All monster movement, including attacking the player (including special
  10. * attacks) is handled here.
  11. * Also handles loading and saving monster state data.
  12. *
  13. * =============================================================================
  14. * EXPORTED VARIABLES
  15. *
  16. * monstnamelist : The character code for displaying each monster
  17. * monsttilelist : The gfx tile for each monster
  18. * monster : The monster data
  19. * lastmonst : The name of the last monster being processed.
  20. * last_monst_id : The id of the last monster being processed.
  21. * last_monst_hx : The x location of the last monster hit by the player
  22. * last_monst_hy : The y location of the last monster hit by the player
  23. * rmst : The random monster creation countdown.
  24. *
  25. * =============================================================================
  26. * EXPORTED FUNCTIONS
  27. *
  28. * createmonster
  29. * mon_has_item : Checks if a monster has a specific item
  30. * fullhit : Do full damage to a monster
  31. * ifblind : Display the monster hir, accounting for blindness
  32. * hitmonster : Function to hit a monster
  33. * hitm : Function to just hit a monster (no checks for AC)
  34. * hitplayer : Function for a monster to hit the player
  35. * makemonst : Make a monster number appropriate to a dungeon level
  36. * randmonst : Create a random monster on the current cave level
  37. * teleportmonst : Teleport a monster
  38. * movemonst : Move monsters.
  39. * parse2 : Function to call when player is not to move, but monsters are
  40. * write_monster_data : Function to write the monster data to the save file
  41. * read_monster_data : Function to read the monster data from the save file
  42. *
  43. * =============================================================================
  44. */
  45. #ifndef __MONSTER_H
  46. #define __MONSTER_H
  47. #include "dungeon.h"
  48. #define MAXMONST 57 /* maximum # monsters in the dungeon */
  49. struct monst {
  50. char *name;
  51. char level;
  52. char armorclass;
  53. char damage;
  54. char attack;
  55. char intelligence;
  56. short gold;
  57. short hitpoints;
  58. long experience;
  59. long flags;
  60. };
  61. /*
  62. * Flags for monst structure
  63. */
  64. #define FL_NONE 0x00 /* Nothing of interest */
  65. #define FL_GENOCIDED 0x01 /* Monster has been genocided */
  66. #define FL_HEAD 0x02 /* Monster has a head */
  67. #define FL_NOBEHEAD 0x04 /* Monster cannot be beheaded by Vorpy */
  68. #define FL_SLOW 0x08 /* Monster moves at 1/2 nornal speed */
  69. #define FL_FLY 0x10 /* Monster can fly over pits and trapdoors */
  70. #define FL_SPIRIT 0x20 /* Is a spirit (affected by spirit prot) */
  71. #define FL_UNDEAD 0x40 /* Is undead (affected by undead prot) */
  72. #define FL_INFRAVIS 0x80 /* Monster has infravision (see invisible) */
  73. /************* Defines for the monsters as objects *************/
  74. typedef enum {
  75. MONST_NONE,
  76. LEMMING,
  77. GNOME,
  78. HOBGOBLIN,
  79. JACKAL,
  80. KOBOLD,
  81. ORC,
  82. SNAKE,
  83. CENTIPEDE,
  84. JACULI,
  85. TROGLODYTE,
  86. ANT,
  87. EYE,
  88. LEPRECHAUN,
  89. NYMPH,
  90. QUASIT,
  91. RUSTMONSTER,
  92. ZOMBIE,
  93. ASSASSINBUG,
  94. BUGBEAR,
  95. HELLHOUND,
  96. ICELIZARD,
  97. CENTAUR,
  98. TROLL,
  99. YETI,
  100. WHITEDRAGON,
  101. ELF,
  102. CUBE,
  103. METAMORPH,
  104. VORTEX,
  105. ZILLER,
  106. VIOLETFUNGI,
  107. WRAITH,
  108. FORVALAKA,
  109. LAMANOBE,
  110. OSEQUIP,
  111. ROTHE,
  112. XORN,
  113. VAMPIRE,
  114. INVISIBLESTALKER,
  115. POLTERGEIST,
  116. DISENCHANTRESS,
  117. SHAMBLINGMOUND,
  118. YELLOWMOLD,
  119. UMBERHULK,
  120. GNOMEKING,
  121. MIMIC,
  122. WATERLORD,
  123. BRONZEDRAGON,
  124. GREENDRAGON,
  125. PURPLEWORM,
  126. XVART,
  127. SPIRITNAGA,
  128. SILVERDRAGON,
  129. PLATINUMDRAGON,
  130. GREENURCHIN,
  131. REDDRAGON,
  132. DEMONLORD,
  133. DEMONLORD_II,
  134. DEMONLORD_III,
  135. DEMONLORD_IV,
  136. DEMONLORD_V,
  137. DEMONLORD_VI,
  138. DEMONLORD_VII,
  139. DEMONPRINCE,
  140. LUCIFER,
  141. MONST_COUNT
  142. } MonsterIdType;
  143. /*
  144. * Character codes to use for monsters
  145. */
  146. extern char monstnamelist[MONST_COUNT];
  147. /*
  148. * Tile numbers to use for monsters
  149. */
  150. extern int monsttilelist[MONST_COUNT];
  151. /*
  152. * The monster data
  153. */
  154. extern struct monst monster[MONST_COUNT];
  155. /*
  156. * Name of the current monster
  157. */
  158. extern char lastmonst[40];
  159. /* number of the last monster hitting the player */
  160. extern MonsterIdType last_monst_id;
  161. extern int last_monst_hx; /* x location of the last monster hit by player */
  162. extern int last_monst_hy; /* y location of the last monster hit by player */
  163. extern char rmst; /* Random monster creation timer */
  164. /* =============================================================================
  165. * FUNCTION: createmonster
  166. *
  167. * DESCRIPTION:
  168. * Function to create a monster next to the player.
  169. *
  170. * PARAMETERS:
  171. *
  172. * mon : The id of the monster to create.
  173. *
  174. * RETURN VALUE:
  175. *
  176. * None.
  177. */
  178. void createmonster(MonsterIdType mon);
  179. /* =============================================================================
  180. * FUNCTION: mon_has_item
  181. *
  182. * DESCRIPTION:
  183. * This function returns true if the monster at location x, y has Item
  184. * in its inventory.
  185. * If there is no monster at x, y then the function returns false.
  186. *
  187. * PARAMETERS:
  188. *
  189. * x : The x location to check
  190. *
  191. * y : The y location to check
  192. *
  193. * Item : The item to check for.
  194. *
  195. * RETURN VALUE:
  196. *
  197. * true if the monster at (x, y) has Item, false otherwise.
  198. */
  199. int mon_has_item(int x, int y, int Item);
  200. /* =============================================================================
  201. * FUNCTION: fullhit
  202. *
  203. * DESCRIPTION:
  204. * Function to return hp damage to monster due to a number of full hits.
  205. *
  206. * PARAMETERS:
  207. *
  208. * xx : The number of full hits.
  209. *
  210. * RETURN VALUE:
  211. *
  212. * The total damage done by xx full hits.
  213. */
  214. int fullhit(int xx);
  215. /* =============================================================================
  216. * FUNCTION: ifblind
  217. *
  218. * DESCRIPTION:
  219. * Subroutine to copy the word "monster" into lastmonst if the player is blind,
  220. * or the monster name if not.
  221. *
  222. * PARAMETERS:
  223. *
  224. * x : The x location of the monster
  225. *
  226. * y : The y location of the monster
  227. *
  228. * RETURN VALUE:
  229. *
  230. * None.
  231. */
  232. void ifblind(int x, int y);
  233. /* =============================================================================
  234. * FUNCTION: hitmonster
  235. *
  236. * DESCRIPTION:
  237. * Function to hit a monster at the designated coordinates.
  238. * This routine is used for a bash & slash type attack on a monster.
  239. *
  240. * PARAMETERS:
  241. *
  242. * x : The x location of the monster
  243. *
  244. * y : The y location of the monster
  245. *
  246. * RETURN VALUE:
  247. *
  248. * None
  249. */
  250. void hitmonster(int x, int y);
  251. /* =============================================================================
  252. * FUNCTION: hitm
  253. *
  254. * DESCRIPTION:
  255. * Function to just hit a monster at a given coordinates.
  256. * This routine is used to specifically damage a monster at a location.
  257. * The function handles damage from both weapons and spells.
  258. *
  259. * PARAMETERS:
  260. *
  261. * x : The x location of the monster.
  262. *
  263. * y : The y location of the monster.
  264. *
  265. * amt : The amount of damage being dealt.
  266. *
  267. * SpellFlag : This flag is to be set to true if the damage is from a spell.
  268. *
  269. * RETURN VALUE:
  270. *
  271. * Returns the number of hitpoints the monster absorbed.
  272. */
  273. int hitm(int x, int y, int amt, int SpellFlag);
  274. /* =============================================================================
  275. * FUNCTION: hitplayer
  276. *
  277. * DESCRIPTION:
  278. * Function for the monster at the designated location to hit the player.
  279. *
  280. * PARAMETERS:
  281. *
  282. * x : The x location of the monster.
  283. *
  284. * y : THe y location of the monster.
  285. *
  286. * RETURN VALUE:
  287. *
  288. * None.
  289. */
  290. void hitplayer(int x, int y);
  291. /* =============================================================================
  292. * FUNCTION: makemonst
  293. *
  294. * DESCRIPTION:
  295. * Function to return monster number for a randomly selected monster for the
  296. * given cave level.
  297. *
  298. * PARAMETERS:
  299. *
  300. * lev : The cave level for the monster
  301. *
  302. * RETURN VALUE:
  303. *
  304. * None.
  305. */
  306. int makemonst(int lev);
  307. /* =============================================================================
  308. * FUNCTION: randmonst
  309. *
  310. * DESCRIPTION:
  311. * Function to randomly create monsters if needed.
  312. *
  313. * PARAMETERS:
  314. *
  315. * None.
  316. *
  317. * RETURN VALUE:
  318. *
  319. * None.
  320. */
  321. void randmonst(void);
  322. /* =============================================================================
  323. * FUNCTION: teleportmonst
  324. *
  325. * DESCRIPTION:
  326. * Function to teleport a monster.
  327. *
  328. * PARAMETERS:
  329. *
  330. * xx : The x location of the monster
  331. *
  332. * yy : The y location of the monster
  333. *
  334. * monst : The monster id.
  335. *
  336. * RETURN VALUE:
  337. *
  338. * None.
  339. */
  340. void teleportmonst(int xx, int yy, int monst);
  341. /* =============================================================================
  342. * FUNCTION: movemonst
  343. *
  344. * DESCRIPTION:
  345. * This routine has the responsibility to determine which monsters are to
  346. * move, and to perform the movement.
  347. *
  348. * PARAMETERS:
  349. *
  350. * None.
  351. *
  352. * RETURN VALUE:
  353. *
  354. * None.
  355. */
  356. void movemonst(void);
  357. /* =============================================================================
  358. * FUNCTION: parse2
  359. *
  360. * DESCRIPTION:
  361. * Move things while player is out of action.
  362. *
  363. * PARAMETERS:
  364. *
  365. * None.
  366. *
  367. * RETURN VALUE:
  368. *
  369. * None.
  370. */
  371. void parse2(void);
  372. /* =============================================================================
  373. * FUNCTION: write_monster_data
  374. *
  375. * DESCRIPTION:
  376. * Function to write the monster data to the save file.
  377. *
  378. * PARAMETERS:
  379. *
  380. * fp : A pointer to the save file being written.
  381. *
  382. * RETURN VALUE:
  383. *
  384. * None.
  385. */
  386. void write_monster_data(FILE *fp);
  387. /* =============================================================================
  388. * FUNCTION: read_monster_data
  389. *
  390. * DESCRIPTION:
  391. * Function to read the monster data from the save file.
  392. *
  393. * PARAMETERS:
  394. *
  395. * fp : A pointer to the save file being read.
  396. *
  397. * RETURN VALUE:
  398. *
  399. * None.
  400. */
  401. void read_monster_data(FILE *fp);
  402. #endif