monster.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. {
  76. MONST_NONE,
  77. LEMMING,
  78. GNOME,
  79. HOBGOBLIN,
  80. JACKAL,
  81. KOBOLD,
  82. ORC,
  83. SNAKE,
  84. CENTIPEDE,
  85. JACULI,
  86. TROGLODYTE,
  87. ANT,
  88. EYE,
  89. LEPRECHAUN,
  90. NYMPH,
  91. QUASIT,
  92. RUSTMONSTER,
  93. ZOMBIE,
  94. ASSASSINBUG,
  95. BUGBEAR,
  96. HELLHOUND,
  97. ICELIZARD,
  98. CENTAUR,
  99. TROLL,
  100. YETI,
  101. WHITEDRAGON,
  102. ELF,
  103. CUBE,
  104. METAMORPH,
  105. VORTEX,
  106. ZILLER,
  107. VIOLETFUNGI,
  108. WRAITH,
  109. FORVALAKA,
  110. LAMANOBE,
  111. OSEQUIP,
  112. ROTHE,
  113. XORN,
  114. VAMPIRE,
  115. INVISIBLESTALKER,
  116. POLTERGEIST,
  117. DISENCHANTRESS,
  118. SHAMBLINGMOUND,
  119. YELLOWMOLD,
  120. UMBERHULK,
  121. GNOMEKING,
  122. MIMIC,
  123. WATERLORD,
  124. BRONZEDRAGON,
  125. GREENDRAGON,
  126. PURPLEWORM,
  127. XVART,
  128. SPIRITNAGA,
  129. SILVERDRAGON,
  130. PLATINUMDRAGON,
  131. GREENURCHIN,
  132. REDDRAGON,
  133. DEMONLORD,
  134. DEMONLORD_II,
  135. DEMONLORD_III,
  136. DEMONLORD_IV,
  137. DEMONLORD_V,
  138. DEMONLORD_VI,
  139. DEMONLORD_VII,
  140. DEMONPRINCE,
  141. LUCIFER,
  142. MONST_COUNT
  143. } MonsterIdType;
  144. /*
  145. * Character codes to use for monsters
  146. */
  147. extern char monstnamelist[MONST_COUNT];
  148. /*
  149. * Tile numbers to use for monsters
  150. */
  151. extern int monsttilelist[MONST_COUNT];
  152. /*
  153. * The monster data
  154. */
  155. extern struct monst monster[MONST_COUNT];
  156. /*
  157. * Name of the current monster
  158. */
  159. extern char lastmonst[40];
  160. /* number of the last monster hitting the player */
  161. extern MonsterIdType last_monst_id;
  162. extern int last_monst_hx; /* x location of the last monster hit by player */
  163. extern int last_monst_hy; /* y location of the last monster hit by player */
  164. extern char rmst; /* Random monster creation timer */
  165. /* =============================================================================
  166. * FUNCTION: createmonster
  167. *
  168. * DESCRIPTION:
  169. * Function to create a monster next to the player.
  170. *
  171. * PARAMETERS:
  172. *
  173. * mon : The id of the monster to create.
  174. *
  175. * RETURN VALUE:
  176. *
  177. * None.
  178. */
  179. void createmonster(MonsterIdType mon);
  180. /* =============================================================================
  181. * FUNCTION: mon_has_item
  182. *
  183. * DESCRIPTION:
  184. * This function returns true if the monster at location x, y has Item
  185. * in its inventory.
  186. * If there is no monster at x, y then the function returns false.
  187. *
  188. * PARAMETERS:
  189. *
  190. * x : The x location to check
  191. *
  192. * y : The y location to check
  193. *
  194. * Item : The item to check for.
  195. *
  196. * RETURN VALUE:
  197. *
  198. * true if the monster at (x, y) has Item, false otherwise.
  199. */
  200. int mon_has_item(int x, int y, int Item);
  201. /* =============================================================================
  202. * FUNCTION: fullhit
  203. *
  204. * DESCRIPTION:
  205. * Function to return hp damage to monster due to a number of full hits.
  206. *
  207. * PARAMETERS:
  208. *
  209. * xx : The number of full hits.
  210. *
  211. * RETURN VALUE:
  212. *
  213. * The total damage done by xx full hits.
  214. */
  215. int fullhit(int xx);
  216. /* =============================================================================
  217. * FUNCTION: ifblind
  218. *
  219. * DESCRIPTION:
  220. * Subroutine to copy the word "monster" into lastmonst if the player is blind,
  221. * or the monster name if not.
  222. *
  223. * PARAMETERS:
  224. *
  225. * x : The x location of the monster
  226. *
  227. * y : The y location of the monster
  228. *
  229. * RETURN VALUE:
  230. *
  231. * None.
  232. */
  233. void ifblind(int x, int y);
  234. /* =============================================================================
  235. * FUNCTION: hitmonster
  236. *
  237. * DESCRIPTION:
  238. * Function to hit a monster at the designated coordinates.
  239. * This routine is used for a bash & slash type attack on a monster.
  240. *
  241. * PARAMETERS:
  242. *
  243. * x : The x location of the monster
  244. *
  245. * y : The y location of the monster
  246. *
  247. * RETURN VALUE:
  248. *
  249. * None
  250. */
  251. void hitmonster(int x, int y);
  252. /* =============================================================================
  253. * FUNCTION: hitm
  254. *
  255. * DESCRIPTION:
  256. * Function to just hit a monster at a given coordinates.
  257. * This routine is used to specifically damage a monster at a location.
  258. * The function handles damage from both weapons and spells.
  259. *
  260. * PARAMETERS:
  261. *
  262. * x : The x location of the monster.
  263. *
  264. * y : The y location of the monster.
  265. *
  266. * amt : The amount of damage being dealt.
  267. *
  268. * SpellFlag : This flag is to be set to true if the damage is from a spell.
  269. *
  270. * RETURN VALUE:
  271. *
  272. * Returns the number of hitpoints the monster absorbed.
  273. */
  274. int hitm(int x, int y, int amt, int SpellFlag);
  275. /* =============================================================================
  276. * FUNCTION: hitplayer
  277. *
  278. * DESCRIPTION:
  279. * Function for the monster at the designated location to hit the player.
  280. *
  281. * PARAMETERS:
  282. *
  283. * x : The x location of the monster.
  284. *
  285. * y : THe y location of the monster.
  286. *
  287. * RETURN VALUE:
  288. *
  289. * None.
  290. */
  291. void hitplayer (int x, int y);
  292. /* =============================================================================
  293. * FUNCTION: makemonst
  294. *
  295. * DESCRIPTION:
  296. * Function to return monster number for a randomly selected monster for the
  297. * given cave level.
  298. *
  299. * PARAMETERS:
  300. *
  301. * lev : The cave level for the monster
  302. *
  303. * RETURN VALUE:
  304. *
  305. * None.
  306. */
  307. int makemonst(int lev);
  308. /* =============================================================================
  309. * FUNCTION: randmonst
  310. *
  311. * DESCRIPTION:
  312. * Function to randomly create monsters if needed.
  313. *
  314. * PARAMETERS:
  315. *
  316. * None.
  317. *
  318. * RETURN VALUE:
  319. *
  320. * None.
  321. */
  322. void randmonst (void);
  323. /* =============================================================================
  324. * FUNCTION: teleportmonst
  325. *
  326. * DESCRIPTION:
  327. * Function to teleport a monster.
  328. *
  329. * PARAMETERS:
  330. *
  331. * xx : The x location of the monster
  332. *
  333. * yy : The y location of the monster
  334. *
  335. * monst : The monster id.
  336. *
  337. * RETURN VALUE:
  338. *
  339. * None.
  340. */
  341. void teleportmonst (int xx, int yy, int monst);
  342. /* =============================================================================
  343. * FUNCTION: movemonst
  344. *
  345. * DESCRIPTION:
  346. * This routine has the responsibility to determine which monsters are to
  347. * move, and to perform the movement.
  348. *
  349. * PARAMETERS:
  350. *
  351. * None.
  352. *
  353. * RETURN VALUE:
  354. *
  355. * None.
  356. */
  357. void movemonst(void);
  358. /* =============================================================================
  359. * FUNCTION: parse2
  360. *
  361. * DESCRIPTION:
  362. * Move things while player is out of action.
  363. *
  364. * PARAMETERS:
  365. *
  366. * None.
  367. *
  368. * RETURN VALUE:
  369. *
  370. * None.
  371. */
  372. void parse2(void);
  373. /* =============================================================================
  374. * FUNCTION: write_monster_data
  375. *
  376. * DESCRIPTION:
  377. * Function to write the monster data to the save file.
  378. *
  379. * PARAMETERS:
  380. *
  381. * fp : A pointer to the save file being written.
  382. *
  383. * RETURN VALUE:
  384. *
  385. * None.
  386. */
  387. void write_monster_data(FILE *fp);
  388. /* =============================================================================
  389. * FUNCTION: read_monster_data
  390. *
  391. * DESCRIPTION:
  392. * Function to read the monster data from the save file.
  393. *
  394. * PARAMETERS:
  395. *
  396. * fp : A pointer to the save file being read.
  397. *
  398. * RETURN VALUE:
  399. *
  400. * None.
  401. */
  402. void read_monster_data(FILE *fp);
  403. #endif