home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume14 / umoria4 / part18 < prev    next >
Internet Message Format  |  1992-08-31  |  58KB

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i050:  umoria4 - single player dungeon simulation (ver. 5.5), Part18/39
  5. Message-ID: <3408@master.CNA.TEK.COM>
  6. Date: 20 Aug 92 18:05:51 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1980
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: grabiner@math.harvard.edu (David Grabiner)
  12. Posting-number: Volume 14, Issue 50
  13. Archive-name: umoria4/Part18
  14. Supersedes: umoria3: Volume 9, Issue 55-97; Volume 10, Issue 15-17
  15. Environment: Curses, Unix, Mac, MS-DOS, Atari-ST, Amiga, VMS
  16.  
  17.  
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of archive 18 (of 39)."
  26. # Contents:  source/player.c source/spells.c.1 util/mc/st.h
  27. # Wrapped by billr@saab on Thu Aug 20 09:11:30 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'source/player.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'source/player.c'\"
  31. else
  32. echo shar: Extracting \"'source/player.c'\" \(19531 characters\)
  33. sed "s/^X//" >'source/player.c' <<'END_OF_FILE'
  34. X/* source/player.c: player specific variable definitions
  35. X
  36. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  37. X
  38. X   This software may be copied and distributed for educational, research, and
  39. X   not for profit purposes provided that this copyright and statement are
  40. X   included in all such copies. */
  41. X
  42. X#include "config.h"
  43. X#include "constant.h"
  44. X#include "types.h"
  45. X
  46. X/* Player record for most player related info */
  47. Xplayer_type py;
  48. X/* player location in dungeon */
  49. Xint16 char_row;
  50. Xint16 char_col;
  51. X/* calculated base hp values for player at each level, store them so that
  52. X   drain life + restore life does not affect hit points */
  53. Xint16u player_hp[MAX_PLAYER_LEVEL];
  54. X
  55. X/* Class titles for different levels                */
  56. X#ifdef MACGAME
  57. Xchar *(*player_title)[MAX_PLAYER_LEVEL];
  58. X#else
  59. Xchar *player_title[MAX_CLASS][MAX_PLAYER_LEVEL] = {
  60. X    /* Warrior     */
  61. X{"Rookie","Private","Soldier","Mercenary","Veteran(1st)","Veteran(2nd)",
  62. X"Veteran(3rd)","Warrior(1st)","Warrior(2nd)","Warrior(3rd)","Warrior(4th)",
  63. X"Swordsman-1","Swordsman-2","Swordsman-3","Hero","Swashbuckler","Myrmidon",
  64. X"Champion-1","Champion-2","Champion-3","Superhero","Knight","Superior Knt",
  65. X"Gallant Knt","Knt Errant","Guardian Knt","Baron","Duke","Lord (1st)",
  66. X"Lord (2nd)","Lord (3rd)","Lord (4th)","Lord (5th)","Lord (6th)","Lord (7th)",
  67. X"Lord (8th)","Lord (9th)","Lord Gallant","Lord Keeper","Lord Noble"},
  68. X    /* Mage         */
  69. X{"Novice","Apprentice","Trickster-1","Trickster-2","Trickster-3","Cabalist-1",
  70. X"Cabalist-2","Cabalist-3","Visionist","Phantasmist","Shadowist","Spellbinder",
  71. X"Illusionist","Evoker (1st)","Evoker (2nd)","Evoker (3rd)","Evoker (4th)",
  72. X"Conjurer","Theurgist","Thaumaturge","Magician","Enchanter","Warlock",
  73. X"Sorcerer","Necromancer","Mage (1st)","Mage (2nd)","Mage (3rd)","Mage (4th)",
  74. X"Mage (5th)","Wizard (1st)","Wizard (2nd)","Wizard (3rd)","Wizard (4th)",
  75. X"Wizard (5th)","Wizard (6th)","Wizard (7th)","Wizard (8th)","Wizard (9th)",
  76. X"Wizard Lord"},
  77. X    /* Priests     */
  78. X{"Believer","Acolyte(1st)","Acolyte(2nd)","Acolyte(3rd)","Adept (1st)",
  79. X"Adept (2nd)","Adept (3rd)","Priest (1st)","Priest (2nd)","Priest (3rd)",
  80. X"Priest (4th)","Priest (5th)","Priest (6th)","Priest (7th)","Priest (8th)",
  81. X"Priest (9th)","Curate (1st)","Curate (2nd)","Curate (3rd)","Curate (4th)",
  82. X"Curate (5th)","Curate (6th)","Curate (7th)","Curate (8th)","Curate (9th)",
  83. X"Canon (1st)","Canon (2nd)","Canon (3rd)","Canon (4th)","Canon (5th)",
  84. X"Low Lama","Lama-1","Lama-2","Lama-3","High Lama","Great Lama","Patriarch",
  85. X"High Priest","Great Priest","Noble Priest"},
  86. X    /* Rogues     */
  87. X{"Vagabond","Footpad","Cutpurse","Robber","Burglar","Filcher","Sharper",
  88. X"Magsman","Common Rogue","Rogue (1st)","Rogue (2nd)","Rogue (3rd)",
  89. X"Rogue (4th)","Rogue (5th)","Rogue (6th)","Rogue (7th)","Rogue (8th)",
  90. X"Rogue (9th)","Master Rogue","Expert Rogue","Senior Rogue","Chief Rogue",
  91. X"Prime Rogue","Low Thief","Thief (1st)","Thief (2nd)","Thief (3rd)",
  92. X"Thief (4th)","Thief (5th)","Thief (6th)","Thief (7th)","Thief (8th)",
  93. X"Thief (9th)","High Thief","Master Thief","Executioner","Low Assassin",
  94. X"Assassin","High Assassin","Guildsmaster"},
  95. X    /* Rangers     */
  96. X{"Runner (1st)","Runner (2nd)","Runner (3rd)","Strider (1st)","Strider (2nd)",
  97. X"Strider (3rd)","Scout (1st)","Scout (2nd)","Scout (3rd)","Scout (4th)",
  98. X"Scout (5th)","Courser (1st)","Courser (2nd)","Courser (3rd)","Courser (4th)",
  99. X"Courser (5th)","Tracker (1st)","Tracker (2nd)","Tracker (3rd)",
  100. X"Tracker (4th)","Tracker (5th)","Tracker (6th)","Tracker (7th)",
  101. X"Tracker (8th)","Tracker (9th)","Guide (1st)","Guide (2nd)","Guide (3rd)",
  102. X"Guide (4th)","Guide (5th)","Guide (6th)","Guide (7th)","Guide (8th)",
  103. X"Guide (9th)","Pathfinder-1","Pathfinder-2","Pathfinder-3","Ranger",
  104. X"High Ranger","Ranger Lord"},
  105. X    /* Paladins     */
  106. X{"Gallant","Keeper (1st)","Keeper (2nd)","Keeper (3rd)","Keeper (4th)",
  107. X"Keeper (5th)","Keeper (6th)","Keeper (7th)","Keeper (8th)","Keeper (9th)",
  108. X"Protector-1","Protector-2","Protector-3","Protector-4","Protector-5",
  109. X"Protector-6","Protector-7","Protector-8","Defender-1","Defender-2",
  110. X"Defender-3","Defender-4","Defender-5","Defender-6","Defender-7","Defender-8",
  111. X"Warder (1st)","Warder (2nd)","Warder (3rd)","Warder (4th)","Warder (5th)",
  112. X"Warder (6th)","Warder (7th)","Warder (8th)","Warder (9th)","Guardian",
  113. X"Chevalier","Justiciar","Paladin","High Lord"}
  114. X};
  115. X#endif
  116. X
  117. X/* Base experience levels, may be adjusted up for race and/or class*/
  118. Xint32u player_exp[MAX_PLAYER_LEVEL] = {
  119. X      10,      25,    45,     70,      100,        140,      200,    280,
  120. X     380,     500,     650,    850,     1100,       1400,     1800,     2300,
  121. X    2900,    3600,    4400,    5400,     6800,       8400,    10200,    12500,
  122. X   17500,   25000,  35000L,  50000L,   75000L,    100000L,  150000L,  200000L,
  123. X 300000L, 400000L, 500000L, 750000L, 1500000L, 2500000L, 5000000L, 10000000L
  124. X};
  125. X
  126. X/*Race    STR,INT,WIS,DEX,CON,CHR,
  127. X    Ages, heights, and weights (male then female)
  128. X    Racial Bases for: dis,srh,stl,fos,bth,bthb,bsav,hitdie,
  129. X    infra, exp base, choice-classes */
  130. X#ifdef MACGAME
  131. Xrace_type *race;
  132. X#else
  133. Xrace_type race[MAX_RACES] = {
  134. X   {"Human",     0,  0,     0,  0,     0,  0,
  135. X      14,  6, 72,  6,180, 25, 66,  4,150, 20,
  136. X      0,  0,  0,  0,  0,  0,  0, 10,  0, 100, 0x3F,
  137. X    },
  138. X   {"Half-Elf", -1,  1,     0,  1, -1,  1,
  139. X      24, 16, 66,  6,130, 15, 62,  6,100, 10,
  140. X      2,  6,  1, -1, -1,  5,  3,  9,  2, 110, 0x3F,
  141. X    },
  142. X   {"Elf",    -1,  2,     1,  1, -2,  1,
  143. X      75, 75, 60,  4,100,  6, 54,  4, 80,  6,
  144. X      5,  8,  1, -2, -5, 15,  6,  8,  3, 120, 0x1F,
  145. X    },
  146. X   {"Halfling", -2,  2,     1,  3,     1,  1,
  147. X      21, 12, 36,  3, 60,  3, 33,  3, 50,  3,
  148. X      15, 12,  4, -5,-10, 20, 18,  6,  4, 110, 0x0B,
  149. X    },
  150. X   {"Gnome",    -1,  2,     0,  2,     1, -2,
  151. X      50, 40, 42,  3, 90,  6, 39,  3, 75,  3,
  152. X      10,  6,  3, -3, -8, 12, 12,  7,  4, 125, 0x0F,
  153. X    },
  154. X   {"Dwarf",     2, -3,     1, -2,     2, -3,
  155. X      35, 15, 48,  3,150, 10, 46,  3,120, 10,
  156. X      2,  7,  -1,  0, 15,  0,  9,  9,  5, 120, 0x05,
  157. X    },
  158. X   {"Half-Orc",     2, -1,     0,  0,     1, -4,
  159. X      11,  4, 66,  1,150,  5, 62,  1,120,  5,
  160. X      -3,  0, -1,  3, 12, -5, -3, 10,  3, 110, 0x0D,
  161. X    },
  162. X   {"Half-Troll",4, -4, -2, -4,     3, -6,
  163. X      20, 10, 96, 10,255, 50, 84,  8,225, 40,
  164. X      -5, -1, -2,  5, 20,-10, -8, 12,  3, 120, 0x05,
  165. X    }
  166. X };
  167. X#endif
  168. X
  169. X/* Background information                    */
  170. X#ifdef MACGAME
  171. Xbackground_type *background;
  172. X#else
  173. Xbackground_type background[MAX_BACKGROUND] = {
  174. X{"You are the illegitimate and unacknowledged child ",         10, 1, 2, 25},
  175. X{"You are the illegitimate but acknowledged child ",         20, 1, 2, 35},
  176. X{"You are one of several children ",                 95, 1, 2, 45},
  177. X{"You are the first child ",                    100, 1, 2, 50},
  178. X{"of a Serf.  ",                         40, 2, 3, 65},
  179. X{"of a Yeoman.  ",                         65, 2, 3, 80},
  180. X{"of a Townsman.  ",                         80, 2, 3, 90},
  181. X{"of a Guildsman.  ",                         90, 2, 3,105},
  182. X{"of a Landed Knight.  ",                     96, 2, 3,120},
  183. X{"of a Titled Noble.  ",                     99, 2, 3,130},
  184. X{"of a Royal Blood Line.  ",                    100, 2, 3,140},
  185. X{"You are the black sheep of the family.  ",             20, 3,50, 20},
  186. X{"You are a credit to the family.  ",                 80, 3,50, 55},
  187. X{"You are a well liked child.  ",                100, 3,50, 60},
  188. X{"Your mother was a Green-Elf.  ",                 40, 4, 1, 50},
  189. X{"Your father was a Green-Elf.  ",                 75, 4, 1, 55},
  190. X{"Your mother was a Grey-Elf.  ",                 90, 4, 1, 55},
  191. X{"Your father was a Grey-Elf.  ",                 95, 4, 1, 60},
  192. X{"Your mother was a High-Elf.  ",                 98, 4, 1, 65},
  193. X{"Your father was a High-Elf.  ",                100, 4, 1, 70},
  194. X{"You are one of several children ",                 60, 7, 8, 50},
  195. X{"You are the only child ",                    100, 7, 8, 55},
  196. X{"of a Green-Elf ",                         75, 8, 9, 50},
  197. X{"of a Grey-Elf ",                         95, 8, 9, 55},
  198. X{"of a High-Elf ",                        100, 8, 9, 60},
  199. X{"Ranger.  ",                             40, 9,54, 80},
  200. X{"Archer.  ",                             70, 9,54, 90},
  201. X{"Warrior.  ",                             87, 9,54,110},
  202. X{"Mage.  ",                             95, 9,54,125},
  203. X{"Prince.  ",                             99, 9,54,140},
  204. X{"King.  ",                            100, 9,54,145},
  205. X{"You are one of several children of a Halfling ",         85,10,11, 45},
  206. X{"You are the only child of a Halfling ",            100,10,11, 55},
  207. X{"Bum.  ",                             20,11, 3, 55},
  208. X{"Tavern Owner.  ",                         30,11, 3, 80},
  209. X{"Miller.  ",                             40,11, 3, 90},
  210. X{"Home Owner.  ",                         50,11, 3,100},
  211. X{"Burglar.  ",                             80,11, 3,110},
  212. X{"Warrior.  ",                             95,11, 3,115},
  213. X{"Mage.  ",                             99,11, 3,125},
  214. X{"Clan Elder.  ",                        100,11, 3,140},
  215. X{"You are one of several children of a Gnome ",             85,13,14, 45},
  216. X{"You are the only child of a Gnome ",                100,13,14, 55},
  217. X{"Beggar.  ",                             20,14, 3, 55},
  218. X{"Braggart.  ",                             50,14, 3, 70},
  219. X{"Prankster.  ",                         75,14, 3, 85},
  220. X{"Warrior.  ",                             95,14, 3,100},
  221. X{"Mage.  ",                            100,14, 3,125},
  222. X{"You are one of two children of a Dwarven ",             25,16,17, 40},
  223. X{"You are the only child of a Dwarven ",            100,16,17, 50},
  224. X{"Thief.  ",                             10,17,18, 60},
  225. X{"Prison Guard.  ",                         25,17,18, 75},
  226. X{"Miner.  ",                             75,17,18, 90},
  227. X{"Warrior.  ",                             90,17,18,110},
  228. X{"Priest.  ",                             99,17,18,130},
  229. X{"King.  ",                            100,17,18,150},
  230. X{"You are the black sheep of the family.  ",             15,18,57, 10},
  231. X{"You are a credit to the family.  ",                 85,18,57, 50},
  232. X{"You are a well liked child.  ",                100,18,57, 55},
  233. X{"Your mother was an Orc, but it is unacknowledged.  ",         25,19,20, 25},
  234. X{"Your father was an Orc, but it is unacknowledged.  ",        100,19,20, 25},
  235. X{"You are the adopted child ",                    100,20, 2, 50},
  236. X{"Your mother was a Cave-Troll ",                 30,22,23, 20},
  237. X{"Your father was a Cave-Troll ",                 60,22,23, 25},
  238. X{"Your mother was a Hill-Troll ",                 75,22,23, 30},
  239. X{"Your father was a Hill-Troll ",                 90,22,23, 35},
  240. X{"Your mother was a Water-Troll ",                 95,22,23, 40},
  241. X{"Your father was a Water-Troll ",                100,22,23, 45},
  242. X{"Cook.  ",                              5,23,62, 60},
  243. X{"Warrior.  ",                             95,23,62, 55},
  244. X{"Shaman.  ",                             99,23,62, 65},
  245. X{"Clan Chief.  ",                        100,23,62, 80},
  246. X{"You have dark brown eyes, ",                     20,50,51, 50},
  247. X{"You have brown eyes, ",                     60,50,51, 50},
  248. X{"You have hazel eyes, ",                     70,50,51, 50},
  249. X{"You have green eyes, ",                     80,50,51, 50},
  250. X{"You have blue eyes, ",                     90,50,51, 50},
  251. X{"You have blue-gray eyes, ",                    100,50,51, 50},
  252. X{"straight ",                             70,51,52, 50},
  253. X{"wavy ",                             90,51,52, 50},
  254. X{"curly ",                            100,51,52, 50},
  255. X{"black hair, ",                         30,52,53, 50},
  256. X{"brown hair, ",                         70,52,53, 50},
  257. X{"auburn hair, ",                         80,52,53, 50},
  258. X{"red hair, ",                             90,52,53, 50},
  259. X{"blond hair, ",                        100,52,53, 50},
  260. X{"and a very dark complexion.",                     10,53, 0, 50},
  261. X{"and a dark complexion.",                     30,53, 0, 50},
  262. X{"and an average complexion.",                     80,53, 0, 50},
  263. X{"and a fair complexion.",                     90,53, 0, 50},
  264. X{"and a very fair complexion.",                    100,53, 0, 50},
  265. X{"You have light grey eyes, ",                     85,54,55, 50},
  266. X{"You have light blue eyes, ",                     95,54,55, 50},
  267. X{"You have light green eyes, ",                    100,54,55, 50},
  268. X{"straight ",                             75,55,56, 50},
  269. X{"wavy ",                            100,55,56, 50},
  270. X{"black hair, and a fair complexion.",                 75,56, 0, 50},
  271. X{"brown hair, and a fair complexion.",                 85,56, 0, 50},
  272. X{"blond hair, and a fair complexion.",                 95,56, 0, 50},
  273. X{"silver hair, and a fair complexion.",                100,56, 0, 50},
  274. X{"You have dark brown eyes, ",                     99,57,58, 50},
  275. X{"You have glowing red eyes, ",                    100,57,58, 60},
  276. X{"straight ",                             90,58,59, 50},
  277. X{"wavy ",                            100,58,59, 50},
  278. X{"black hair, ",                         75,59,60, 50},
  279. X{"brown hair, ",                        100,59,60, 50},
  280. X{"a one foot beard, ",                         25,60,61, 50},
  281. X{"a two foot beard, ",                         60,60,61, 51},
  282. X{"a three foot beard, ",                     90,60,61, 53},
  283. X{"a four foot beard, ",                        100,60,61, 55},
  284. X{"and a dark complexion.",                    100,61, 0, 50},
  285. X{"You have slime green eyes, ",                     60,62,63, 50},
  286. X{"You have puke yellow eyes, ",                     85,62,63, 50},
  287. X{"You have blue-bloodshot eyes, ",                 99,62,63, 50},
  288. X{"You have glowing red eyes, ",                    100,62,63, 55},
  289. X{"dirty ",                             33,63,64, 50},
  290. X{"mangy ",                             66,63,64, 50},
  291. X{"oily ",                            100,63,64, 50},
  292. X{"sea-weed green hair, ",                     33,64,65, 50},
  293. X{"bright red hair, ",                         66,64,65, 50},
  294. X{"dark purple hair, ",                        100,64,65, 50},
  295. X{"and green ",                             25,65,66, 50},
  296. X{"and blue ",                             50,65,66, 50},
  297. X{"and white ",                             75,65,66, 50},
  298. X{"and black ",                            100,65,66, 50},
  299. X{"ulcerous skin.",                         33,66, 0, 50},
  300. X{"scabby skin.",                         66,66, 0, 50},
  301. X{"leprous skin.",                        100,66, 0, 50}
  302. X};
  303. X#endif
  304. X
  305. X/* Classes.                            */
  306. Xclass_type class[MAX_CLASS] = {
  307. X/*      HP Dis Src Stl Fos bth btb sve S  I  W  D Co Ch  Spell Exp  spl */
  308. X{"Warrior",9, 25, 14, 1, 38, 70, 55, 18, 5,-2,-2, 2, 2,-1, NONE,    0, 0},
  309. X{"Mage",   0, 30, 16, 2, 20, 34, 20, 36,-5, 3, 0, 1,-2, 1, MAGE,   30, 1},
  310. X{"Priest", 2, 25, 16, 2, 32, 48, 35, 30,-3,-3, 3,-1, 0, 2, PRIEST, 20, 1},
  311. X{"Rogue",  6, 45, 32, 5, 16, 60, 66, 30, 2, 1,-2, 3, 1,-1, MAGE,    0, 5},
  312. X{"Ranger", 4, 30, 24, 3, 24, 56, 72, 30, 2, 2, 0, 1, 1, 1, MAGE,   40, 3},
  313. X{"Paladin",6, 20, 12, 1, 38, 68, 40, 24, 3,-3, 1, 0, 2, 2, PRIEST, 35, 1}
  314. X};
  315. X
  316. X/* making it 16 bits wastes a little space, but saves much signed/unsigned
  317. X   headaches in its use */
  318. X/* CLA_MISC_HIT is identical to CLA_SAVE, which takes advantage of
  319. X   the fact that the save values are independent of the class */
  320. Xint16 class_level_adj[MAX_CLASS][MAX_LEV_ADJ] = {
  321. X/*           bth    bthb   device  disarm   save/misc hit  */
  322. X/* Warrior */ {    4,    4,    2,    2,    3 },
  323. X/* Mage    */ { 2,    2,    4,    3,    3 },
  324. X/* Priest  */ { 2,    2,    4,    3,    3 },
  325. X/* Rogue   */ { 3,    4,    3,    4,    3 },
  326. X/* Ranger  */ { 3,    4,    3,    3,    3 },
  327. X/* Paladin */ { 3,    3,    3,    2,    3 }
  328. X};
  329. X
  330. Xint32u spell_learned = 0;    /* bit mask of spells learned */
  331. Xint32u spell_worked = 0;    /* bit mask of spells tried and worked */
  332. Xint32u spell_forgotten = 0;    /* bit mask of spells learned but forgotten */
  333. Xint8u spell_order[32];        /* order spells learned/remembered/forgotten */
  334. X
  335. X/* Warriors don't have spells, so there is no entry for them.  Note that
  336. X   this means you must always subtract one from the py.misc.pclass before
  337. X   indexing into magic_spell[]. */
  338. X#ifdef MACGAME
  339. Xspell_type (*magic_spell)[31];
  340. X#else
  341. Xspell_type magic_spell[MAX_CLASS-1][31] = {
  342. X  {          /* Mage       */
  343. X     {    1,  1, 22,   1},
  344. X     {    1,  1, 23,   1},
  345. X     {    1,  2, 24,   1},
  346. X     {    1,  2, 26,   1},
  347. X     {    3,  3, 25,   2},
  348. X     {    3,  3, 25,   1},
  349. X     {    3,  3, 27,   2},
  350. X     {    3,  4, 30,   1},
  351. X     {    5,  4, 30,   6},
  352. X     {    5,  5, 30,   8},
  353. X     {    5,  5, 30,   5},
  354. X     {    5,  5, 35,   6},
  355. X     {    7,  6, 35,   9},
  356. X     {    7,  6, 50,  10},
  357. X     {    7,  6, 40,  12},
  358. X     {    9,  7, 44,  19},
  359. X     {    9,  7, 45,  19},
  360. X     {    9,  7, 75,  22},
  361. X     {    9,  7, 45,  19},
  362. X     { 11,  7, 45,  25},
  363. X     { 11,  7, 99,  19},
  364. X     { 13,  7, 50,  22},
  365. X     { 15,  9, 50,  25},
  366. X     { 17,  9, 50,  31},
  367. X     { 19, 12, 55,  38},
  368. X     { 21, 12, 90,  44},
  369. X     { 23, 12, 60,  50},
  370. X     { 25, 12, 65,  63},
  371. X     { 29, 18, 65,  88},
  372. X     { 33, 21, 80, 125},
  373. X     { 37, 25, 95, 200}
  374. X   },
  375. X   {          /* Priest       */
  376. X     {    1,  1, 10,   1},
  377. X     {    1,  2, 15,   1},
  378. X     {    1,  2, 20,   1},
  379. X     {    1,  2, 25,   1},
  380. X     {    3,  2, 25,   1},
  381. X     {    3,  3, 27,   2},
  382. X     {    3,  3, 27,   2},
  383. X     {    3,  3, 28,   3},
  384. X     {    5,  4, 29,   4},
  385. X     {    5,  4, 30,   5},
  386. X     {    5,  4, 32,   5},
  387. X     {    5,  5, 34,   5},
  388. X     {    7,  5, 36,   6},
  389. X     {    7,  5, 38,   7},
  390. X     {    7,  6, 38,   9},
  391. X     {    7,  7, 38,   9},
  392. X     {    9,  6, 38,  10},
  393. X     {    9,  7, 38,  10},
  394. X     {    9,  7, 40,  10},
  395. X     { 11,  8, 42,  10},
  396. X     { 11,  8, 42,  12},
  397. X     { 11,  9, 55,  15},
  398. X     { 13, 10, 45,  15},
  399. X     { 13, 11, 45,  16},
  400. X     { 15, 12, 50,  20},
  401. X     { 15, 14, 50,  22},
  402. X     { 17, 14, 55,  32},
  403. X     { 21, 16, 60,  38},
  404. X     { 25, 20, 70,  75},
  405. X     { 33, 24, 90, 125},
  406. X     { 39, 32, 99, 200}
  407. X   },
  408. X   {          /* Rogue       */
  409. X     { 99, 99,    0,   0},
  410. X     {    5,  1, 50,   1},
  411. X     {    7,  2, 55,   1},
  412. X     {    9,  3, 60,   2},
  413. X     { 11,  4, 65,   2},
  414. X     { 13,  5, 70,   3},
  415. X     { 99, 99,    0,   0},
  416. X     { 15,  6, 75,   3},
  417. X     { 99, 99,    0,   0},
  418. X     { 17,  7, 80,   4},
  419. X     { 19,  8, 85,   5},
  420. X     { 21,  9, 90,   6},
  421. X     { 99, 99,    0,   0},
  422. X     { 23, 10, 95,   7},
  423. X     { 99, 99,    0,   0},
  424. X     { 99, 99,    0,   0},
  425. X     { 25, 12, 95,   9},
  426. X     { 27, 15, 99,  11},
  427. X     { 99, 99,    0,   0},
  428. X     { 99, 99,    0,   0},
  429. X     { 29, 18, 99,  19},
  430. X     { 99, 99,    0,   0},
  431. X     { 99, 99,    0,   0},
  432. X     { 99, 99,    0,   0},
  433. X     { 99, 99,    0,   0},
  434. X     { 99, 99,    0,   0},
  435. X     { 99, 99,    0,   0},
  436. X     { 99, 99,    0,   0},
  437. X     { 99, 99,    0,   0},
  438. X     { 99, 99,    0,   0},
  439. X     { 99, 99,    0,   0},
  440. X   },
  441. X   {           /* Ranger        */
  442. X     {    3,  1, 30,   1},
  443. X     {    3,  2, 35,   2},
  444. X     {    3,  2, 35,   2},
  445. X     {    5,  3, 35,   2},
  446. X     {    5,  3, 40,   2},
  447. X     {    5,  4, 45,   3},
  448. X     {    7,  5, 40,   6},
  449. X     {    7,  6, 40,   5},
  450. X     {    9,  7, 40,   7},
  451. X     {    9,  8, 45,   8},
  452. X     { 11,  8, 40,  10},
  453. X     { 11,  9, 45,  10},
  454. X     { 13, 10, 45,  12},
  455. X     { 13, 11, 55,  13},
  456. X     { 15, 12, 50,  15},
  457. X     { 15, 13, 50,  15},
  458. X     { 17, 17, 55,  15},
  459. X     { 17, 17, 90,  17},
  460. X     { 21, 17, 55,  17},
  461. X     { 21, 19, 60,  18},
  462. X     { 23, 25, 95,  20},
  463. X     { 23, 20, 60,  20},
  464. X     { 25, 20, 60,  20},
  465. X     { 25, 21, 65,  20},
  466. X     { 27, 21, 65,  22},
  467. X     { 29, 23, 95,  23},
  468. X     { 31, 25, 70,  25},
  469. X     { 33, 25, 75,  38},
  470. X     { 35, 25, 80,  50},
  471. X     { 37, 30, 95, 100},
  472. X     { 99, 99,    0,   0}
  473. X   },
  474. X   {          /* Paladin       */
  475. X     {    1,  1, 30,   1},
  476. X     {    2,  2, 35,   2},
  477. X     {    3,  3, 35,   3},
  478. X     {    5,  3, 35,   5},
  479. X     {    5,  4, 35,   5},
  480. X     {    7,  5, 40,   6},
  481. X     {    7,  5, 40,   6},
  482. X     {    9,  7, 40,   7},
  483. X     {    9,  7, 40,   8},
  484. X     {    9,  8, 40,   8},
  485. X     { 11,  9, 40,  10},
  486. X     { 11, 10, 45,  10},
  487. X     { 11, 10, 45,  10},
  488. X     { 13, 10, 45,  12},
  489. X     { 13, 11, 45,  13},
  490. X     { 15, 13, 45,  15},
  491. X     { 15, 15, 50,  15},
  492. X     { 17, 15, 50,  17},
  493. X     { 17, 15, 50,  18},
  494. X     { 19, 15, 50,  19},
  495. X     { 19, 15, 50,  19},
  496. X     { 21, 17, 50,  20},
  497. X     { 23, 17, 50,  20},
  498. X     { 25, 20, 50,  20},
  499. X     { 27, 21, 50,  22},
  500. X     { 29, 22, 50,  24},
  501. X     { 31, 24, 60,  25},
  502. X     { 33, 28, 60,  31},
  503. X     { 35, 32, 70,  38},
  504. X     { 37, 36, 90,  50},
  505. X     { 39, 38, 95, 100}
  506. X   }
  507. X };
  508. X#endif
  509. X
  510. Xchar *spell_names[62] = {
  511. X  /* Mage Spells */
  512. X  "Magic Missile",  "Detect Monsters",    "Phase Door",  "Light Area",
  513. X  "Cure Light Wounds",    "Find Hidden Traps/Doors",  "Stinking Cloud",
  514. X  "Confusion",    "Lightning Bolt",  "Trap/Door Destruction", "Sleep I",
  515. X  "Cure Poison",  "Teleport Self",  "Remove Curse",  "Frost Bolt",
  516. X  "Turn Stone to Mud",    "Create Food",    "Recharge Item I",  "Sleep II",
  517. X  "Polymorph Other",  "Identify",  "Sleep III",     "Fire Bolt",  "Slow Monster",
  518. X  "Frost Ball",     "Recharge Item II", "Teleport Other",    "Haste Self",
  519. X  "Fire Ball", "Word of Destruction", "Genocide",
  520. X  /* Priest Spells, start at index 31 */
  521. X  "Detect Evil",  "Cure Light Wounds",    "Bless",  "Remove Fear", "Call Light",
  522. X  "Find Traps",     "Detect Doors/Stairs",     "Slow Poison",     "Blind Creature",
  523. X  "Portal",  "Cure Medium Wounds",  "Chant",  "Sanctuary",  "Create Food",
  524. X  "Remove Curse",  "Resist Heat and Cold",  "Neutralize Poison",
  525. X  "Orb of Draining",  "Cure Serious Wounds",  "Sense Invisible",
  526. X  "Protection from Evil",  "Earthquake",  "Sense Surroundings",
  527. X  "Cure Critical Wounds",  "Turn Undead",  "Prayer",  "Dispel Undead",
  528. X  "Heal",  "Dispel Evil",  "Glyph of Warding",    "Holy Word"
  529. X};
  530. X
  531. X/* Each type of character starts out with a few provisions.    */
  532. X/* Note that the entries refer to elements of the object_list[] array*/
  533. X/* 344 = Food Ration, 365 = Wooden Torch, 123 = Cloak, 318 = Beginners-Majik,
  534. X   103 = Soft Leather Armor, 30 = Stiletto, 322 = Beginners Handbook */
  535. X
  536. Xint16u player_init[MAX_CLASS][5] = {
  537. X        { 344, 365, 123,  30, 103},    /* Warrior     */
  538. X        { 344, 365, 123,  30, 318},    /* Mage         */
  539. X        { 344, 365, 123,  30, 322},    /* Priest     */
  540. X        { 344, 365, 123,  30, 318},    /* Rogue     */
  541. X        { 344, 365, 123,  30, 318},    /* Ranger     */
  542. X        { 344, 365, 123,  30, 322}    /* Paladin     */
  543. X};
  544. END_OF_FILE
  545. if test 19531 -ne `wc -c <'source/player.c'`; then
  546.     echo shar: \"'source/player.c'\" unpacked with wrong size!
  547. fi
  548. # end of 'source/player.c'
  549. fi
  550. if test -f 'source/spells.c.1' -a "${1}" != "-c" ; then 
  551.   echo shar: Will not clobber existing file \"'source/spells.c.1'\"
  552. else
  553. echo shar: Extracting \"'source/spells.c.1'\" \(31713 characters\)
  554. sed "s/^X//" >'source/spells.c.1' <<'END_OF_FILE'
  555. X/* source/spells.c: player/creature spells, breaths, wands, scrolls, etc. code
  556. X
  557. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  558. X
  559. X   This software may be copied and distributed for educational, research, and
  560. X   not for profit purposes provided that this copyright and statement are
  561. X   included in all such copies. */
  562. X
  563. X#ifdef __TURBOC__
  564. X#include    <stdio.h>
  565. X#include    <stdlib.h>
  566. X#endif /* __TURBOC__ */
  567. X#include "config.h"
  568. X#include "constant.h"
  569. X#include "types.h"
  570. X#include "externs.h"
  571. X
  572. X#ifdef USG
  573. X#ifndef ATARIST_MWC
  574. X#include <string.h>
  575. X#endif
  576. X#else
  577. X#include <strings.h>
  578. X#endif
  579. X
  580. X#if defined(LINT_ARGS)
  581. Xstatic void replace_spot(int, int, int);
  582. X#else
  583. Xstatic void replace_spot();
  584. X#endif
  585. X
  586. X/* Following are spell procedure/functions            -RAK-    */
  587. X/* These routines are commonly used in the scroll, potion, wands, and     */
  588. X/* staves routines, and are occasionally called from other areas.      */
  589. X/* Now included are creature spells also.               -RAK    */
  590. X
  591. Xvoid monster_name (m_name, m_ptr, r_ptr)
  592. Xchar *m_name;
  593. Xmonster_type *m_ptr;
  594. Xcreature_type *r_ptr;
  595. X{
  596. X  if (!m_ptr->ml)
  597. X    (void) strcpy (m_name, "It");
  598. X  else
  599. X    (void) sprintf (m_name, "The %s", r_ptr->name);
  600. X}
  601. X
  602. Xvoid lower_monster_name (m_name, m_ptr, r_ptr)
  603. Xchar *m_name;
  604. Xmonster_type *m_ptr;
  605. Xcreature_type *r_ptr;
  606. X{
  607. X  if (!m_ptr->ml)
  608. X    (void) strcpy (m_name, "it");
  609. X  else
  610. X    (void) sprintf (m_name, "the %s", r_ptr->name);
  611. X}
  612. X
  613. X/* Sleep creatures adjacent to player            -RAK-    */
  614. Xint sleep_monsters1(y, x)
  615. Xint y, x;
  616. X{
  617. X  register int i, j;
  618. X  register cave_type *c_ptr;
  619. X  register monster_type *m_ptr;
  620. X  register creature_type *r_ptr;
  621. X  int sleep;
  622. X  vtype out_val, m_name;
  623. X
  624. X  sleep = FALSE;
  625. X  for (i = y-1; i <= y+1; i++)
  626. X    for (j = x-1; j <= x+1; j++)
  627. X      {
  628. X    c_ptr = &cave[i][j];
  629. X    if (c_ptr->cptr > 1)
  630. X      {
  631. X        m_ptr = &m_list[c_ptr->cptr];
  632. X        r_ptr = &c_list[m_ptr->mptr];
  633. X
  634. X        monster_name (m_name, m_ptr, r_ptr);
  635. X        if ((randint(MAX_MONS_LEVEL) < r_ptr->level) ||
  636. X        (CD_NO_SLEEP & r_ptr->cdefense))
  637. X          {
  638. X        if (m_ptr->ml && (r_ptr->cdefense & CD_NO_SLEEP))
  639. X          c_recall[m_ptr->mptr].r_cdefense |= CD_NO_SLEEP;
  640. X        (void) sprintf(out_val, "%s is unaffected.", m_name);
  641. X        msg_print(out_val);
  642. X          }
  643. X        else
  644. X          {
  645. X        sleep = TRUE;
  646. X        m_ptr->csleep = 500;
  647. X        (void) sprintf(out_val, "%s falls asleep.", m_name);
  648. X        msg_print(out_val);
  649. X          }
  650. X      }
  651. X      }
  652. X  return(sleep);
  653. X}
  654. X
  655. X/* Detect any treasure on the current panel        -RAK-    */
  656. Xint detect_treasure()
  657. X{
  658. X  register int i, j, detect;
  659. X  register cave_type *c_ptr;
  660. X
  661. X  detect = FALSE;
  662. X  for (i = panel_row_min; i <= panel_row_max; i++)
  663. X    for (j = panel_col_min; j <= panel_col_max; j++)
  664. X      {
  665. X    c_ptr = &cave[i][j];
  666. X    if ((c_ptr->tptr != 0) && (t_list[c_ptr->tptr].tval == TV_GOLD) &&
  667. X        !test_light(i, j))
  668. X      {
  669. X        c_ptr->fm = TRUE;
  670. X        lite_spot(i, j);
  671. X        detect = TRUE;
  672. X      }
  673. X      }
  674. X  return(detect);
  675. X}
  676. X
  677. X
  678. X/* Detect all objects on the current panel        -RAK-    */
  679. Xint detect_object()
  680. X{
  681. X  register int i, j, detect;
  682. X  register cave_type *c_ptr;
  683. X
  684. X  detect = FALSE;
  685. X  for (i = panel_row_min; i <= panel_row_max; i++)
  686. X    for (j = panel_col_min; j <= panel_col_max; j++)
  687. X      {
  688. X    c_ptr = &cave[i][j];
  689. X    if ((c_ptr->tptr != 0) && (t_list[c_ptr->tptr].tval < TV_MAX_OBJECT)
  690. X        && !test_light(i, j))
  691. X      {
  692. X        c_ptr->fm = TRUE;
  693. X        lite_spot(i, j);
  694. X        detect = TRUE;
  695. X      }
  696. X      }
  697. X  return(detect);
  698. X}
  699. X
  700. X
  701. X/* Locates and displays traps on current panel        -RAK-    */
  702. Xint detect_trap()
  703. X{
  704. X  register int i, j;
  705. X  int detect;
  706. X  register cave_type *c_ptr;
  707. X  register inven_type *t_ptr;
  708. X
  709. X  detect = FALSE;
  710. X  for (i = panel_row_min; i <= panel_row_max; i++)
  711. X    for (j = panel_col_min; j <= panel_col_max; j++)
  712. X      {
  713. X    c_ptr = &cave[i][j];
  714. X    if (c_ptr->tptr != 0)
  715. X      if (t_list[c_ptr->tptr].tval == TV_INVIS_TRAP)
  716. X        {
  717. X          c_ptr->fm = TRUE;
  718. X          change_trap(i, j);
  719. X          detect = TRUE;
  720. X        }
  721. X      else if (t_list[c_ptr->tptr].tval == TV_CHEST)
  722. X        {
  723. X          t_ptr = &t_list[c_ptr->tptr];
  724. X          known2(t_ptr);
  725. X        }
  726. X      }
  727. X  return(detect);
  728. X}
  729. X
  730. X
  731. X/* Locates and displays all secret doors on current panel -RAK-    */
  732. Xint detect_sdoor()
  733. X{
  734. X  register int i, j, detect;
  735. X  register cave_type *c_ptr;
  736. X
  737. X  detect = FALSE;
  738. X  for (i = panel_row_min; i <= panel_row_max; i++)
  739. X    for (j = panel_col_min; j <= panel_col_max; j++)
  740. X      {
  741. X    c_ptr = &cave[i][j];
  742. X    if (c_ptr->tptr != 0)
  743. X      /* Secret doors  */
  744. X      if (t_list[c_ptr->tptr].tval == TV_SECRET_DOOR)
  745. X        {
  746. X          c_ptr->fm = TRUE;
  747. X          change_trap(i, j);
  748. X          detect = TRUE;
  749. X        }
  750. X    /* Staircases     */
  751. X      else if (((t_list[c_ptr->tptr].tval == TV_UP_STAIR) ||
  752. X            (t_list[c_ptr->tptr].tval == TV_DOWN_STAIR)) &&
  753. X           !c_ptr->fm)
  754. X        {
  755. X          c_ptr->fm = TRUE;
  756. X          lite_spot(i, j);
  757. X          detect = TRUE;
  758. X        }
  759. X      }
  760. X  return(detect);
  761. X}
  762. X
  763. X
  764. X/* Locates and displays all invisible creatures on current panel -RAK-*/
  765. Xint detect_invisible()
  766. X{
  767. X  register int i, flag;
  768. X  register monster_type *m_ptr;
  769. X#ifdef ATARIST_MWC
  770. X  int32u holder;
  771. X#endif
  772. X
  773. X  flag = FALSE;
  774. X  for (i = mfptr - 1; i >= MIN_MONIX; i--)
  775. X    {
  776. X      m_ptr = &m_list[i];
  777. X      if (panel_contains((int)m_ptr->fy, (int)m_ptr->fx) &&
  778. X#ifdef ATARIST_MWC
  779. X      ((holder = CM_INVISIBLE) & c_list[m_ptr->mptr].cmove))
  780. X#else
  781. X      (CM_INVISIBLE & c_list[m_ptr->mptr].cmove))
  782. X#endif
  783. X    {
  784. X      m_ptr->ml = TRUE;
  785. X      /* works correctly even if hallucinating */
  786. X      print((char)c_list[m_ptr->mptr].cchar, (int)m_ptr->fy,
  787. X        (int)m_ptr->fx);
  788. X      flag = TRUE;
  789. X    }
  790. X    }
  791. X  if (flag)
  792. X    {
  793. X      msg_print("You sense the presence of invisible creatures!");
  794. X      msg_print(CNIL);
  795. X      /* must unlight every monster just lighted */
  796. X      creatures(FALSE);
  797. X    }
  798. X  return(flag);
  799. X}
  800. X
  801. X
  802. X/* Light an area: 1.  If corridor  light immediate area -RAK-*/
  803. X/*          2.  If room  light entire room plus immediate area.     */
  804. Xint light_area(y, x)
  805. Xregister int y, x;
  806. X{
  807. X  register int i, j, light;
  808. X
  809. X  if (py.flags.blind < 1)
  810. X    msg_print("You are surrounded by a white light.");
  811. X  light = TRUE;
  812. X  if (cave[y][x].lr && (dun_level > 0))
  813. X    light_room(y, x);
  814. X  /* Must always light immediate area, because one might be standing on
  815. X     the edge of a room, or next to a destroyed area, etc.  */
  816. X  for (i = y-1; i <= y+1; i++)
  817. X    for (j = x-1; j <=  x+1; j++)
  818. X      {
  819. X    cave[i][j].pl = TRUE;
  820. X    lite_spot(i, j);
  821. X      }
  822. X  return(light);
  823. X}
  824. X
  825. X
  826. X/* Darken an area, opposite of light area        -RAK-    */
  827. Xint unlight_area(y, x)
  828. Xint y, x;
  829. X{
  830. X  register int i, j;
  831. X  int tmp1, tmp2, unlight;
  832. X  int start_row, start_col, end_row, end_col;
  833. X  register cave_type *c_ptr;
  834. X
  835. X  unlight = FALSE;
  836. X  if (cave[y][x].lr && (dun_level > 0))
  837. X    {
  838. X      tmp1 = (SCREEN_HEIGHT/2);
  839. X      tmp2 = (SCREEN_WIDTH /2);
  840. X      start_row = (y/tmp1)*tmp1 + 1;
  841. X      start_col = (x/tmp2)*tmp2 + 1;
  842. X      end_row = start_row + tmp1 - 1;
  843. X      end_col = start_col + tmp2 - 1;
  844. X      for (i = start_row; i <= end_row; i++)
  845. X    {
  846. X      for (j = start_col; j <= end_col; j++)
  847. X        {
  848. X          c_ptr = &cave[i][j];
  849. X          if (c_ptr->lr && c_ptr->fval <= MAX_CAVE_FLOOR)
  850. X        {
  851. X          c_ptr->pl = FALSE;
  852. X          c_ptr->fval = DARK_FLOOR;
  853. X          lite_spot (i, j);
  854. X          if (!test_light(i, j))
  855. X            unlight = TRUE;
  856. X        }
  857. X        }
  858. X    }
  859. X    }
  860. X  else
  861. X    for (i = y-1; i <= y+1; i++)
  862. X      for (j = x-1; j <= x+1; j++)
  863. X    {
  864. X      c_ptr = &cave[i][j];
  865. X      if ((c_ptr->fval == CORR_FLOOR) && c_ptr->pl)
  866. X        {
  867. X          /* pl could have been set by star-lite wand, etc */
  868. X          c_ptr->pl = FALSE;
  869. X          unlight = TRUE;
  870. X        }
  871. X    }
  872. X
  873. X  if (unlight && py.flags.blind <= 0)
  874. X    msg_print("Darkness surrounds you.");
  875. X
  876. X  return(unlight);
  877. X}
  878. X
  879. X
  880. X/* Map the current area plus some            -RAK-    */
  881. Xvoid map_area()
  882. X{
  883. X  register cave_type *c_ptr;
  884. X  register int i7, i8, n, m;
  885. X  int i, j, k, l;
  886. X
  887. X  i = panel_row_min - randint(10);
  888. X  j = panel_row_max + randint(10);
  889. X  k = panel_col_min - randint(20);
  890. X  l = panel_col_max + randint(20);
  891. X  for (m = i; m <= j; m++)
  892. X    for (n = k; n <= l; n++)
  893. X      if (in_bounds(m, n) && (cave[m][n].fval <= MAX_CAVE_FLOOR))
  894. X    for (i7 = m-1; i7 <= m+1; i7++)
  895. X      for (i8 = n-1; i8 <= n+1; i8++)
  896. X        {
  897. X          c_ptr = &cave[i7][i8];
  898. X          if (c_ptr->fval >= MIN_CAVE_WALL)
  899. X        c_ptr->pl = TRUE;
  900. X          else if ((c_ptr->tptr != 0) &&
  901. X               (t_list[c_ptr->tptr].tval >= TV_MIN_VISIBLE) &&
  902. X               (t_list[c_ptr->tptr].tval <= TV_MAX_VISIBLE))
  903. X        c_ptr->fm = TRUE;
  904. X        }
  905. X  prt_map();
  906. X}
  907. X
  908. X
  909. X/* Identify an object                    -RAK-    */
  910. Xint ident_spell()
  911. X{
  912. X  int item_val;
  913. X  bigvtype out_val, tmp_str;
  914. X  register int ident;
  915. X  register inven_type *i_ptr;
  916. X
  917. X  ident = FALSE;
  918. X  if (get_item(&item_val, "Item you wish identified?", 0, INVEN_ARRAY_SIZE,
  919. X           CNIL, CNIL))
  920. X    {
  921. X      ident = TRUE;
  922. X      identify(&item_val);
  923. X      i_ptr = &inventory[item_val];
  924. X      known2(i_ptr);
  925. X      objdes(tmp_str, i_ptr, TRUE);
  926. X      if (item_val >= INVEN_WIELD)
  927. X    {
  928. X      calc_bonuses();
  929. X      (void) sprintf (out_val, "%s: %s", describe_use(item_val), tmp_str);
  930. X    }
  931. X      else
  932. X    (void) sprintf(out_val, "%c %s", item_val+97, tmp_str);
  933. X      msg_print(out_val);
  934. X    }
  935. X  return(ident);
  936. X}
  937. X
  938. X
  939. X/* Get all the monsters on the level pissed off.    -RAK-    */
  940. Xint aggravate_monster (dis_affect)
  941. Xint dis_affect;
  942. X{
  943. X  register int i, aggravate;
  944. X  register monster_type *m_ptr;
  945. X
  946. X  aggravate = FALSE;
  947. X  for (i = mfptr - 1; i >= MIN_MONIX; i--)
  948. X    {
  949. X      m_ptr = &m_list[i];
  950. X      m_ptr->csleep = 0;
  951. X      if ((m_ptr->cdis <= dis_affect) && (m_ptr->cspeed < 2))
  952. X    {
  953. X      m_ptr->cspeed++;
  954. X      aggravate = TRUE;
  955. X    }
  956. X    }
  957. X  if (aggravate)
  958. X    msg_print ("You hear a sudden stirring in the distance!");
  959. X  return(aggravate);
  960. X}
  961. X
  962. X
  963. X/* Surround the fool with traps (chuckle)        -RAK-    */
  964. Xint trap_creation()
  965. X{
  966. X  register int i, j, trap;
  967. X  register cave_type *c_ptr;
  968. X
  969. X  trap = TRUE;
  970. X  for (i = char_row-1; i <= char_row+1; i++)
  971. X    for (j = char_col-1; j <= char_col+1; j++)
  972. X      {
  973. X    /* Don't put a trap under the player, since this can lead to
  974. X       strange situations, e.g. falling through a trap door while
  975. X       trying to rest, setting off a falling rock trap and ending
  976. X       up under the rock.  */
  977. X    if (i == char_row && j == char_col)
  978. X      continue;
  979. X    c_ptr = &cave[i][j];
  980. X    if (c_ptr->fval <= MAX_CAVE_FLOOR)
  981. X      {
  982. X        if (c_ptr->tptr != 0)
  983. X          (void) delete_object(i, j);
  984. X        place_trap(i, j, randint(MAX_TRAP)-1);
  985. X        /* don't let player gain exp from the newly created traps */
  986. X        t_list[c_ptr->tptr].p1 = 0;
  987. X        /* open pits are immediately visible, so call lite_spot */
  988. X        lite_spot(i, j);
  989. X      }
  990. X      }
  991. X  return(trap);
  992. X}
  993. X
  994. X
  995. X/* Surround the player with doors.            -RAK-    */
  996. Xint door_creation()
  997. X{
  998. X  register int i, j, door;
  999. X  int k;
  1000. X  register cave_type *c_ptr;
  1001. X
  1002. X  door = FALSE;
  1003. X  for (i = char_row-1; i <= char_row+1; i++)
  1004. X    for (j = char_col-1; j <=  char_col+1; j++)
  1005. X      if ((i != char_row) || (j != char_col))
  1006. X    {
  1007. X      c_ptr = &cave[i][j];
  1008. X      if (c_ptr->fval <= MAX_CAVE_FLOOR)
  1009. X        {
  1010. X          door = TRUE;
  1011. X          if (c_ptr->tptr != 0)
  1012. X        (void) delete_object(i, j);
  1013. X          k = popt();
  1014. X          c_ptr->fval = BLOCKED_FLOOR;
  1015. X          c_ptr->tptr = k;
  1016. X          invcopy(&t_list[k], OBJ_CLOSED_DOOR);
  1017. X          lite_spot(i, j);
  1018. X        }
  1019. X    }
  1020. X  return(door);
  1021. X}
  1022. X
  1023. X
  1024. X/* Destroys any adjacent door(s)/trap(s)        -RAK-    */
  1025. Xint td_destroy()
  1026. X{
  1027. X  register int i, j, destroy;
  1028. X  register cave_type *c_ptr;
  1029. X
  1030. X  destroy = FALSE;
  1031. X  for (i = char_row-1; i <= char_row+1; i++)
  1032. X    for (j = char_col-1; j <= char_col+1; j++)
  1033. X      {
  1034. X    c_ptr = &cave[i][j];
  1035. X    if (c_ptr->tptr != 0)
  1036. X      {
  1037. X        if (((t_list[c_ptr->tptr].tval >= TV_INVIS_TRAP) &&
  1038. X         (t_list[c_ptr->tptr].tval <= TV_CLOSED_DOOR) &&
  1039. X         (t_list[c_ptr->tptr].tval != TV_RUBBLE)) ||
  1040. X        (t_list[c_ptr->tptr].tval == TV_SECRET_DOOR))
  1041. X          {
  1042. X        if (delete_object(i, j))
  1043. X          destroy = TRUE;
  1044. X          }
  1045. X        else if (t_list[c_ptr->tptr].tval == TV_CHEST)
  1046. X          {
  1047. X        /* destroy traps on chest and unlock */
  1048. X        t_list[c_ptr->tptr].flags &= ~(CH_TRAPPED|CH_LOCKED);
  1049. X        t_list[c_ptr->tptr].name2 = SN_UNLOCKED;
  1050. X        msg_print ("You have disarmed the chest.");
  1051. X        known2(&t_list[c_ptr->tptr]);
  1052. X        destroy = TRUE;
  1053. X          }
  1054. X      }
  1055. X      }
  1056. X  return(destroy);
  1057. X}
  1058. X
  1059. X
  1060. X/* Display all creatures on the current panel        -RAK-    */
  1061. Xint detect_monsters()
  1062. X{
  1063. X  register int i, detect;
  1064. X  register monster_type *m_ptr;
  1065. X#ifdef ATARIST_MWC
  1066. X  int32u holder;
  1067. X#endif
  1068. X
  1069. X  detect = FALSE;
  1070. X  for (i = mfptr - 1; i >= MIN_MONIX; i--)
  1071. X    {
  1072. X      m_ptr = &m_list[i];
  1073. X      if (panel_contains((int)m_ptr->fy, (int)m_ptr->fx) &&
  1074. X#ifdef ATARIST_MWC
  1075. X      (((holder = CM_INVISIBLE) & c_list[m_ptr->mptr].cmove) == 0))
  1076. X#else
  1077. X      ((CM_INVISIBLE & c_list[m_ptr->mptr].cmove) == 0))
  1078. X#endif
  1079. X    {
  1080. X      m_ptr->ml = TRUE;
  1081. X      /* works correctly even if hallucinating */
  1082. X      print((char)c_list[m_ptr->mptr].cchar, (int)m_ptr->fy,
  1083. X        (int)m_ptr->fx);
  1084. X      detect = TRUE;
  1085. X    }
  1086. X    }
  1087. X  if (detect)
  1088. X    {
  1089. X      msg_print("You sense the presence of monsters!");
  1090. X      msg_print(CNIL);
  1091. X      /* must unlight every monster just lighted */
  1092. X      creatures(FALSE);
  1093. X    }
  1094. X  return(detect);
  1095. X}
  1096. X
  1097. X
  1098. X/* Leave a line of light in given dir, blue light can sometimes    */
  1099. X/* hurt creatures.                       -RAK-   */
  1100. Xvoid light_line(dir, y, x)
  1101. Xint dir, y, x;
  1102. X{
  1103. X  register int i;
  1104. X  register cave_type *c_ptr;
  1105. X  register monster_type *m_ptr;
  1106. X  register creature_type *r_ptr;
  1107. X  int dist, flag;
  1108. X  vtype out_val, m_name;
  1109. X
  1110. X  dist = -1;
  1111. X  flag = FALSE;
  1112. X  do
  1113. X    {
  1114. X      /* put mmove at end because want to light up current spot */
  1115. X      dist++;
  1116. X      c_ptr = &cave[y][x];
  1117. X      if ((dist > OBJ_BOLT_RANGE) || c_ptr->fval >= MIN_CLOSED_SPACE)
  1118. X    flag = TRUE;
  1119. X      else
  1120. X    {
  1121. X      if (!c_ptr->pl && !c_ptr->tl)
  1122. X        {
  1123. X          /* set pl so that lite_spot will work */
  1124. X          c_ptr->pl = TRUE;
  1125. X          if (c_ptr->fval == LIGHT_FLOOR)
  1126. X        {
  1127. X          if (panel_contains(y, x))
  1128. X            light_room(y, x);
  1129. X        }
  1130. X          else
  1131. X        lite_spot(y, x);
  1132. X        }
  1133. X      /* set pl in case tl was true above */
  1134. X      c_ptr->pl = TRUE;
  1135. X      if (c_ptr->cptr > 1)
  1136. X        {
  1137. X          m_ptr = &m_list[c_ptr->cptr];
  1138. X          r_ptr = &c_list[m_ptr->mptr];
  1139. X          /* light up and draw monster */
  1140. X          update_mon ((int)c_ptr->cptr);
  1141. X          monster_name (m_name, m_ptr, r_ptr);
  1142. X          if (CD_LIGHT & r_ptr->cdefense)
  1143. X        {
  1144. X          if (m_ptr->ml)
  1145. X            c_recall[m_ptr->mptr].r_cdefense |= CD_LIGHT;
  1146. X          i = mon_take_hit((int)c_ptr->cptr, damroll(2, 8));
  1147. X          if (i >= 0)
  1148. X            {
  1149. X              (void) sprintf(out_val,
  1150. X                 "%s shrivels away in the light!", m_name);
  1151. X              msg_print(out_val);
  1152. X              prt_experience();
  1153. X            }
  1154. X          else
  1155. X            {
  1156. X              (void) sprintf(out_val, "%s cringes from the light!",
  1157. X                     m_name);
  1158. X              msg_print (out_val);
  1159. X            }
  1160. X        }
  1161. X        }
  1162. X    }
  1163. X      (void) mmove(dir, &y, &x);
  1164. X    }
  1165. X  while (!flag);
  1166. X}
  1167. X
  1168. X
  1169. X/* Light line in all directions                -RAK-    */
  1170. Xvoid starlite(y, x)
  1171. Xregister int y, x;
  1172. X{
  1173. X  register int i;
  1174. X
  1175. X  if (py.flags.blind < 1)
  1176. X    msg_print("The end of the staff bursts into a blue shimmering light.");
  1177. X  for (i = 1; i <= 9; i++)
  1178. X    if (i != 5)
  1179. X      light_line(i, y, x);
  1180. X}
  1181. X
  1182. X
  1183. X/* Disarms all traps/chests in a given direction    -RAK-    */
  1184. Xint disarm_all(dir, y, x)
  1185. Xint dir, y, x;
  1186. X{
  1187. X  register cave_type *c_ptr;
  1188. X  register inven_type *t_ptr;
  1189. X  register int disarm, dist;
  1190. X
  1191. X  disarm = FALSE;
  1192. X  dist = -1;
  1193. X  do
  1194. X    {
  1195. X      /* put mmove at end, in case standing on a trap */
  1196. X      dist++;
  1197. X      c_ptr = &cave[y][x];
  1198. X      /* note, must continue upto and including the first non open space,
  1199. X     because secret doors have fval greater than MAX_OPEN_SPACE */
  1200. X      if (c_ptr->tptr != 0)
  1201. X    {
  1202. X      t_ptr = &t_list[c_ptr->tptr];
  1203. X      if ((t_ptr->tval == TV_INVIS_TRAP) || (t_ptr->tval == TV_VIS_TRAP))
  1204. X        {
  1205. X          if (delete_object(y, x))
  1206. X        disarm = TRUE;
  1207. X        }
  1208. X      else if (t_ptr->tval == TV_CLOSED_DOOR)
  1209. X        t_ptr->p1 = 0;  /* Locked or jammed doors become merely closed. */
  1210. X      else if (t_ptr->tval == TV_SECRET_DOOR)
  1211. X        {
  1212. X          c_ptr->fm = TRUE;
  1213. X          change_trap(y, x);
  1214. X          disarm = TRUE;
  1215. X        }
  1216. X      else if ((t_ptr->tval == TV_CHEST) && (t_ptr->flags != 0))
  1217. X        {
  1218. X          msg_print("Click!");
  1219. X          t_ptr->flags &= ~(CH_TRAPPED|CH_LOCKED);
  1220. X          disarm = TRUE;
  1221. X          t_ptr->name2 = SN_UNLOCKED;
  1222. X          known2(t_ptr);
  1223. X        }
  1224. X    }
  1225. X      (void) mmove(dir, &y, &x);
  1226. X    }
  1227. X  while ((dist <= OBJ_BOLT_RANGE) && c_ptr->fval <= MAX_OPEN_SPACE);
  1228. X  return(disarm);
  1229. X}
  1230. X
  1231. X
  1232. X/* Return flags for given type area affect        -RAK-    */
  1233. Xvoid get_flags(typ, weapon_type, harm_type, destroy)
  1234. Xint typ;
  1235. Xint32u *weapon_type; int *harm_type;
  1236. Xint (**destroy)();
  1237. X{
  1238. X  switch(typ)
  1239. X    {
  1240. X    case GF_MAGIC_MISSILE:
  1241. X      *weapon_type = 0;
  1242. X      *harm_type   = 0;
  1243. X      *destroy       = set_null;
  1244. X      break;
  1245. X    case GF_LIGHTNING:
  1246. X      *weapon_type = CS_BR_LIGHT;
  1247. X      *harm_type   = CD_LIGHT;
  1248. X      *destroy       = set_lightning_destroy;
  1249. X      break;
  1250. X    case GF_POISON_GAS:
  1251. X      *weapon_type = CS_BR_GAS;
  1252. X      *harm_type   = CD_POISON;
  1253. X      *destroy       = set_null;
  1254. X      break;
  1255. X    case GF_ACID:
  1256. X      *weapon_type = CS_BR_ACID;
  1257. X      *harm_type   = CD_ACID;
  1258. X      *destroy       = set_acid_destroy;
  1259. X      break;
  1260. X    case GF_FROST:
  1261. X      *weapon_type = CS_BR_FROST;
  1262. X      *harm_type   = CD_FROST;
  1263. X      *destroy       = set_frost_destroy;
  1264. X      break;
  1265. X    case GF_FIRE:
  1266. X      *weapon_type = CS_BR_FIRE;
  1267. X      *harm_type   = CD_FIRE;
  1268. X      *destroy       = set_fire_destroy;
  1269. X      break;
  1270. X    case GF_HOLY_ORB:
  1271. X      *weapon_type = 0;
  1272. X      *harm_type   = CD_EVIL;
  1273. X      *destroy       = set_null;
  1274. X      break;
  1275. X    default:
  1276. X      msg_print("ERROR in get_flags()\n");
  1277. X    }
  1278. X}
  1279. X
  1280. X
  1281. X/* Shoot a bolt in a given direction            -RAK-    */
  1282. Xvoid fire_bolt(typ, dir, y, x, dam, bolt_typ)
  1283. Xint typ, dir, y, x, dam;
  1284. Xchar *bolt_typ;
  1285. X{
  1286. X  int i, oldy, oldx, dist, flag;
  1287. X  int32u weapon_type; int harm_type;
  1288. X  int (*dummy)();
  1289. X  register cave_type *c_ptr;
  1290. X  register monster_type *m_ptr;
  1291. X  register creature_type *r_ptr;
  1292. X  vtype out_val, m_name;
  1293. X
  1294. X  flag = FALSE;
  1295. X  get_flags(typ, &weapon_type, &harm_type, &dummy);
  1296. X  oldy = y;
  1297. X  oldx = x;
  1298. X  dist = 0;
  1299. X  do
  1300. X    {
  1301. X      (void) mmove(dir, &y, &x);
  1302. X      dist++;
  1303. X      c_ptr = &cave[y][x];
  1304. X      lite_spot(oldy, oldx);
  1305. X      if ((dist > OBJ_BOLT_RANGE) || c_ptr->fval >= MIN_CLOSED_SPACE)
  1306. X    flag = TRUE;
  1307. X      else
  1308. X    {
  1309. X      if (c_ptr->cptr > 1)
  1310. X        {
  1311. X          flag = TRUE;
  1312. X          m_ptr = &m_list[c_ptr->cptr];
  1313. X          r_ptr = &c_list[m_ptr->mptr];
  1314. X
  1315. X          /* light up monster and draw monster, temporarily set
  1316. X         pl so that update_mon() will work */
  1317. X          i = c_ptr->pl;
  1318. X          c_ptr->pl = TRUE;
  1319. X          update_mon ((int)c_ptr->cptr);
  1320. X          c_ptr->pl = i;
  1321. X          /* draw monster and clear previous bolt */
  1322. X          put_qio();
  1323. X
  1324. X          lower_monster_name(m_name, m_ptr, r_ptr);
  1325. X          (void) sprintf(out_val, "The %s strikes %s.", bolt_typ, m_name);
  1326. X          msg_print(out_val);
  1327. X          if (harm_type & r_ptr->cdefense)
  1328. X        {
  1329. X          dam = dam*2;
  1330. X          if (m_ptr->ml)
  1331. X            c_recall[m_ptr->mptr].r_cdefense |= harm_type;
  1332. X        }
  1333. X          else if (weapon_type & r_ptr->spells)
  1334. X        {
  1335. X          dam = dam / 4;
  1336. X          if (m_ptr->ml)
  1337. X            c_recall[m_ptr->mptr].r_spells |= weapon_type;
  1338. X        }
  1339. X          monster_name(m_name, m_ptr, r_ptr);
  1340. X          i = mon_take_hit((int)c_ptr->cptr, dam);
  1341. X          if (i >= 0)
  1342. X        {
  1343. X          (void) sprintf(out_val, "%s dies in a fit of agony.",
  1344. X                 m_name);
  1345. X          msg_print(out_val);
  1346. X          prt_experience();
  1347. X        }
  1348. X          else if (dam > 0)
  1349. X        {
  1350. X          (void) sprintf (out_val, "%s screams in agony.", m_name);
  1351. X          msg_print (out_val);
  1352. X        }
  1353. X        }
  1354. X      else if (panel_contains(y, x) && (py.flags.blind < 1))
  1355. X        {
  1356. X          print('*', y, x);
  1357. X          /* show the bolt */
  1358. X          put_qio();
  1359. X        }
  1360. X    }
  1361. X      oldy = y;
  1362. X      oldx = x;
  1363. X    }
  1364. X  while (!flag);
  1365. X}
  1366. X
  1367. X
  1368. X/* Shoot a ball in a given direction.  Note that balls have an    */
  1369. X/* area affect.                          -RAK-   */
  1370. Xvoid fire_ball(typ, dir, y, x, dam_hp, descrip)
  1371. Xint typ, dir, y, x, dam_hp;
  1372. Xchar *descrip;
  1373. X{
  1374. X  register int i, j;
  1375. X  int dam, max_dis, thit, tkill, k, tmp;
  1376. X  int oldy, oldx, dist, flag, harm_type;
  1377. X  int32u weapon_type;
  1378. X  int (*destroy)();
  1379. X  register cave_type *c_ptr;
  1380. X  register monster_type *m_ptr;
  1381. X  register creature_type *r_ptr;
  1382. X  vtype out_val;
  1383. X
  1384. X  thit     = 0;
  1385. X  tkill     = 0;
  1386. X  max_dis = 2;
  1387. X  get_flags(typ, &weapon_type, &harm_type, &destroy);
  1388. X  flag = FALSE;
  1389. X  oldy = y;
  1390. X  oldx = x;
  1391. X  dist = 0;
  1392. X  do
  1393. X    {
  1394. X      (void) mmove(dir, &y, &x);
  1395. X      dist++;
  1396. X      lite_spot(oldy, oldx);
  1397. X      if (dist > OBJ_BOLT_RANGE)
  1398. X    flag = TRUE;
  1399. X      else
  1400. X    {
  1401. X      c_ptr = &cave[y][x];
  1402. X      if ((c_ptr->fval >= MIN_CLOSED_SPACE) || (c_ptr->cptr > 1))
  1403. X        {
  1404. X          flag = TRUE;
  1405. X          if (c_ptr->fval >= MIN_CLOSED_SPACE)
  1406. X        {
  1407. X          y = oldy;
  1408. X          x = oldx;
  1409. X        }
  1410. X          /* The ball hits and explodes.             */
  1411. X          /* The explosion.                 */
  1412. X          for (i = y-max_dis; i <= y+max_dis; i++)
  1413. X        for (j = x-max_dis; j <= x+max_dis; j++)
  1414. X          if (in_bounds(i, j) && (distance(y, x, i, j) <= max_dis)
  1415. X              && los(y, x, i, j))
  1416. X            {
  1417. X              c_ptr = &cave[i][j];
  1418. X              if ((c_ptr->tptr != 0) &&
  1419. X              (*destroy)(&t_list[c_ptr->tptr]))
  1420. X            (void) delete_object(i, j);
  1421. X              if (c_ptr->fval <= MAX_OPEN_SPACE)
  1422. X            {
  1423. X              if (c_ptr->cptr > 1)
  1424. X                {
  1425. X                  m_ptr = &m_list[c_ptr->cptr];
  1426. X                  r_ptr = &c_list[m_ptr->mptr];
  1427. X
  1428. X                  /* lite up creature if visible, temp
  1429. X                 set pl so that update_mon works */
  1430. X                  tmp = c_ptr->pl;
  1431. X                  c_ptr->pl = TRUE;
  1432. X                  update_mon((int)c_ptr->cptr);
  1433. X
  1434. X                  thit++;
  1435. X                  dam = dam_hp;
  1436. X                  if (harm_type & r_ptr->cdefense)
  1437. X                {
  1438. X                  dam = dam*2;
  1439. X                  if (m_ptr->ml)
  1440. X                    c_recall[m_ptr->mptr].r_cdefense |=harm_type;
  1441. X                }
  1442. X                  else if (weapon_type & r_ptr->spells)
  1443. X                {
  1444. X                  dam = dam / 4;
  1445. X                  if (m_ptr->ml)
  1446. X                    c_recall[m_ptr->mptr].r_spells |=weapon_type;
  1447. X                }
  1448. X                  dam = (dam/(distance(i, j, y, x)+1));
  1449. X                  k = mon_take_hit((int)c_ptr->cptr, dam);
  1450. X                  if (k >= 0)
  1451. X                tkill++;
  1452. X                  c_ptr->pl = tmp;
  1453. X                }
  1454. X              else if (panel_contains(i, j) &&(py.flags.blind < 1))
  1455. X                print('*', i, j);
  1456. X            }
  1457. X            }
  1458. X          /* show ball of whatever */
  1459. X          put_qio();
  1460. X
  1461. X          for (i = (y - 2); i <= (y + 2); i++)
  1462. X        for (j = (x - 2); j <= (x + 2); j++)
  1463. X          if (in_bounds(i, j) && panel_contains(i, j) &&
  1464. X              (distance(y, x, i, j) <= max_dis))
  1465. X            lite_spot(i, j);
  1466. X
  1467. X          /* End  explosion.             */
  1468. X          if (thit == 1)
  1469. X        {
  1470. X          (void) sprintf(out_val,
  1471. X                 "The %s envelops a creature!",
  1472. X                 descrip);
  1473. X          msg_print(out_val);
  1474. X        }
  1475. X          else if (thit > 1)
  1476. X        {
  1477. X          (void) sprintf(out_val,
  1478. X                 "The %s envelops several creatures!",
  1479. X                 descrip);
  1480. X          msg_print(out_val);
  1481. X        }
  1482. X          if (tkill == 1)
  1483. X        msg_print("There is a scream of agony!");
  1484. X          else if (tkill > 1)
  1485. X        msg_print("There are several screams of agony!");
  1486. X          if (tkill >= 0)
  1487. X        prt_experience();
  1488. X          /* End ball hitting.             */
  1489. X        }
  1490. X      else if (panel_contains(y, x) && (py.flags.blind < 1))
  1491. X        {
  1492. X          print('*', y, x);
  1493. X          /* show bolt */
  1494. X          put_qio();
  1495. X        }
  1496. X      oldy = y;
  1497. X      oldx = x;
  1498. X    }
  1499. X    }
  1500. X  while (!flag);
  1501. X}
  1502. X
  1503. X
  1504. X/* Breath weapon works like a fire_ball, but affects the player. */
  1505. X/* Note the area affect.                  -RAK-   */
  1506. Xvoid breath(typ, y, x, dam_hp, ddesc, monptr)
  1507. Xint typ, y, x, dam_hp;
  1508. Xchar *ddesc;
  1509. Xint monptr;
  1510. X{
  1511. X  register int i, j;
  1512. X  int dam, max_dis, harm_type;
  1513. X  int32u weapon_type;
  1514. X  int32u tmp, treas;
  1515. X  int (*destroy)();
  1516. X  register cave_type *c_ptr;
  1517. X  register monster_type *m_ptr;
  1518. X  register creature_type *r_ptr;
  1519. X#ifdef ATARIST_MWC
  1520. X  int32u holder;
  1521. X#endif
  1522. X
  1523. X  max_dis = 2;
  1524. X  get_flags(typ, &weapon_type, &harm_type, &destroy);
  1525. X  for (i = y-2; i <= y+2; i++)
  1526. X    for (j = x-2; j <= x+2; j++)
  1527. X      if (in_bounds(i, j) && (distance(y, x, i, j) <= max_dis)
  1528. X      && los(y, x, i, j))
  1529. X    {
  1530. X      c_ptr = &cave[i][j];
  1531. X      if ((c_ptr->tptr != 0) &&
  1532. X          (*destroy)(&t_list[c_ptr->tptr]))
  1533. X        (void) delete_object(i, j);
  1534. X      if (c_ptr->fval <= MAX_OPEN_SPACE)
  1535. X        {
  1536. X          /* must test status bit, not py.flags.blind here, flag could have
  1537. X         been set by a previous monster, but the breath should still
  1538. X         be visible until the blindness takes effect */
  1539. X          if (panel_contains(i, j) && !(py.flags.status & PY_BLIND))
  1540. X        print('*', i, j);
  1541. X          if (c_ptr->cptr > 1)
  1542. X        {
  1543. X          m_ptr = &m_list[c_ptr->cptr];
  1544. X          r_ptr = &c_list[m_ptr->mptr];
  1545. X          dam = dam_hp;
  1546. X          if (harm_type & r_ptr->cdefense)
  1547. X            dam = dam*2;
  1548. X          else if (weapon_type & r_ptr->spells)
  1549. X            dam = (dam / 4);
  1550. X          dam = (dam/(distance(i, j, y, x)+1));
  1551. X          /* can not call mon_take_hit here, since player does not
  1552. X             get experience for kill */
  1553. X          m_ptr->hp = m_ptr->hp - dam;
  1554. X          m_ptr->csleep = 0;
  1555. X          if (m_ptr->hp < 0)
  1556. X            {
  1557. X              treas = monster_death((int)m_ptr->fy, (int)m_ptr->fx,
  1558. X                        r_ptr->cmove);
  1559. X              if (m_ptr->ml)
  1560. X            {
  1561. X#ifdef ATARIST_MWC
  1562. X              holder = CM_TREASURE;
  1563. X              tmp = (c_recall[m_ptr->mptr].r_cmove & holder)
  1564. X                >> CM_TR_SHIFT;
  1565. X              if (tmp > ((treas & holder) >> CM_TR_SHIFT))
  1566. X                treas = (treas & ~holder)|(tmp << CM_TR_SHIFT);
  1567. X              c_recall[m_ptr->mptr].r_cmove = treas |
  1568. X                (c_recall[m_ptr->mptr].r_cmove & ~holder);
  1569. X#else
  1570. X              tmp = (c_recall[m_ptr->mptr].r_cmove & CM_TREASURE)
  1571. X                >> CM_TR_SHIFT;
  1572. X              if (tmp > ((treas & CM_TREASURE) >> CM_TR_SHIFT))
  1573. X                treas = (treas & ~CM_TREASURE)|(tmp<<CM_TR_SHIFT);
  1574. X              c_recall[m_ptr->mptr].r_cmove = treas |
  1575. X                (c_recall[m_ptr->mptr].r_cmove & ~CM_TREASURE);
  1576. X#endif
  1577. X            }
  1578. X
  1579. X              /* It ate an already processed monster.Handle normally.*/
  1580. X              if (monptr < c_ptr->cptr)
  1581. X            delete_monster((int) c_ptr->cptr);
  1582. X              /* If it eats this monster, an already processed monster
  1583. X             will take its place, causing all kinds of havoc.
  1584. X             Delay the kill a bit. */
  1585. X              else
  1586. X            fix1_delete_monster((int) c_ptr->cptr);
  1587. X            }
  1588. X        }
  1589. X          else if (c_ptr->cptr == 1)
  1590. X        {
  1591. X          dam = (dam_hp/(distance(i, j, y, x)+1));
  1592. X          /* let's do at least one point of damage */
  1593. X          /* prevents randint(0) problem with poison_gas, also */
  1594. X          if (dam == 0)
  1595. X            dam = 1;
  1596. X          switch(typ)
  1597. X            {
  1598. X            case GF_LIGHTNING: light_dam(dam, ddesc); break;
  1599. X            case GF_POISON_GAS: poison_gas(dam, ddesc); break;
  1600. X            case GF_ACID: acid_dam(dam, ddesc); break;
  1601. X            case GF_FROST: cold_dam(dam, ddesc); break;
  1602. X            case GF_FIRE: fire_dam(dam, ddesc); break;
  1603. X            }
  1604. X        }
  1605. X        }
  1606. X    }
  1607. X  /* show the ball of gas */
  1608. X  put_qio();
  1609. X
  1610. X  for (i = (y - 2); i <= (y + 2); i++)
  1611. X    for (j = (x - 2); j <= (x + 2); j++)
  1612. X      if (in_bounds(i, j) && panel_contains(i, j) &&
  1613. X      (distance(y, x, i, j) <= max_dis))
  1614. X    lite_spot(i, j);
  1615. X}
  1616. X
  1617. X
  1618. X/* Recharge a wand, staff, or rod.  Sometimes the item breaks. -RAK-*/
  1619. Xint recharge(num)
  1620. Xregister int num;
  1621. X{
  1622. X  int i, j, item_val;
  1623. X  register int res;
  1624. X  register inven_type *i_ptr;
  1625. X
  1626. X  res = FALSE;
  1627. X  if (!find_range(TV_STAFF, TV_WAND, &i, &j))
  1628. X    msg_print("You have nothing to recharge.");
  1629. X  else if (get_item(&item_val, "Recharge which item?", i, j, CNIL, CNIL))
  1630. X    {
  1631. X      i_ptr = &inventory[item_val];
  1632. X      res = TRUE;
  1633. X      /* recharge I = recharge(20) = 1/6 failure for empty 10th level wand */
  1634. X      /* recharge II = recharge(60) = 1/10 failure for empty 10th level wand*/
  1635. X      /* make it harder to recharge high level, and highly charged wands, note
  1636. X     that i can be negative, so check its value before trying to call
  1637. X     randint().  */
  1638. X      i = num + 50 - (int)i_ptr->level - i_ptr->p1;
  1639. X      if (i < 19)
  1640. X    i = 1;    /* Automatic failure.  */
  1641. X      else
  1642. X    i = randint (i/10);
  1643. X
  1644. X      if (i == 1)
  1645. X    {
  1646. X      msg_print("There is a bright flash of light.");
  1647. X      inven_destroy(item_val);
  1648. X    }
  1649. X      else
  1650. X    {
  1651. X      num = (num/(i_ptr->level+2)) + 1;
  1652. X      i_ptr->p1 += 2 + randint(num);
  1653. X      if (known2_p(i_ptr))
  1654. X        clear_known2(i_ptr);
  1655. X      clear_empty(i_ptr);
  1656. X    }
  1657. X    }
  1658. X  return(res);
  1659. X}
  1660. X
  1661. X
  1662. X/* Increase or decrease a creatures hit points        -RAK-    */
  1663. Xint hp_monster(dir, y, x, dam)
  1664. Xint dir, y, x, dam;
  1665. X{
  1666. X  register int i;
  1667. X  int flag, dist, monster;
  1668. X  register cave_type *c_ptr;
  1669. X  register monster_type *m_ptr;
  1670. X  register creature_type *r_ptr;
  1671. X  vtype out_val, m_name;
  1672. X
  1673. X  monster = FALSE;
  1674. X  flag = FALSE;
  1675. X  dist = 0;
  1676. X  do
  1677. X    {
  1678. X      (void) mmove(dir, &y, &x);
  1679. X      dist++;
  1680. X      c_ptr = &cave[y][x];
  1681. X      if ((dist > OBJ_BOLT_RANGE) || c_ptr->fval >= MIN_CLOSED_SPACE)
  1682. X    flag = TRUE;
  1683. X      else if (c_ptr->cptr > 1)
  1684. X    {
  1685. X      flag = TRUE;
  1686. X      m_ptr = &m_list[c_ptr->cptr];
  1687. X      r_ptr = &c_list[m_ptr->mptr];
  1688. X      monster_name (m_name, m_ptr, r_ptr);
  1689. X      monster = TRUE;
  1690. X      i = mon_take_hit((int)c_ptr->cptr, dam);
  1691. X      if (i >= 0)
  1692. X        {
  1693. X          (void) sprintf(out_val, "%s dies in a fit of agony.", m_name);
  1694. X          msg_print(out_val);
  1695. X          prt_experience();
  1696. X        }
  1697. X      else if (dam > 0)
  1698. X        {
  1699. X          (void) sprintf(out_val, "%s screams in agony.", m_name);
  1700. X          msg_print(out_val);
  1701. X        }
  1702. X    }
  1703. X    }
  1704. X  while (!flag);
  1705. X  return(monster);
  1706. X}
  1707. X
  1708. X
  1709. X/* Drains life; note it must be living.        -RAK-    */
  1710. Xint drain_life(dir, y, x)
  1711. Xint dir, y, x;
  1712. X{
  1713. X  register int i;
  1714. X  int flag, dist, drain;
  1715. X  register cave_type *c_ptr;
  1716. X  register monster_type *m_ptr;
  1717. X  register creature_type *r_ptr;
  1718. X  vtype out_val, m_name;
  1719. X
  1720. X  drain = FALSE;
  1721. X  flag = FALSE;
  1722. X  dist = 0;
  1723. X  do
  1724. X    {
  1725. X      (void) mmove(dir, &y, &x);
  1726. X      dist++;
  1727. X      c_ptr = &cave[y][x];
  1728. X      if ((dist > OBJ_BOLT_RANGE) || c_ptr->fval >= MIN_CLOSED_SPACE)
  1729. X    flag = TRUE;
  1730. X      else if (c_ptr->cptr > 1)
  1731. X    {
  1732. X      flag = TRUE;
  1733. X      m_ptr = &m_list[c_ptr->cptr];
  1734. X      r_ptr = &c_list[m_ptr->mptr];
  1735. X      if ((r_ptr->cdefense & CD_UNDEAD) == 0)
  1736. X        {
  1737. X          drain = TRUE;
  1738. X          monster_name (m_name, m_ptr, r_ptr);
  1739. X          i = mon_take_hit((int)c_ptr->cptr, 75);
  1740. X          if (i >= 0)
  1741. X        {
  1742. X          (void) sprintf(out_val, "%s dies in a fit of agony.",m_name);
  1743. X          msg_print(out_val);
  1744. X          prt_experience();
  1745. X        }
  1746. X          else
  1747. X        {
  1748. X          (void) sprintf(out_val, "%s screams in agony.", m_name);
  1749. X          msg_print(out_val);
  1750. X        }
  1751. X        }
  1752. X      else
  1753. X        c_recall[m_ptr->mptr].r_cdefense |= CD_UNDEAD;
  1754. X    }
  1755. X    }
  1756. X  while (!flag);
  1757. X  return(drain);
  1758. X}
  1759. X
  1760. X
  1761. X/* Increase or decrease a creatures speed        -RAK-    */
  1762. X/* NOTE: cannot slow a winning creature (BALROG)         */
  1763. Xint speed_monster(dir, y, x, spd)
  1764. Xint dir, y, x, spd;
  1765. X{
  1766. X  int flag, dist, speed;
  1767. X  register cave_type *c_ptr;
  1768. X  register monster_type *m_ptr;
  1769. X  register creature_type *r_ptr;
  1770. X  vtype out_val, m_name;
  1771. X
  1772. X  speed = FALSE;
  1773. X  flag = FALSE;
  1774. X  dist = 0;
  1775. X  do
  1776. X    {
  1777. X      (void) mmove(dir, &y, &x);
  1778. X      dist++;
  1779. X      c_ptr = &cave[y][x];
  1780. X      if ((dist > OBJ_BOLT_RANGE) || c_ptr->fval >= MIN_CLOSED_SPACE)
  1781. X    flag = TRUE;
  1782. X      else if (c_ptr->cptr > 1)
  1783. X    {
  1784. X      flag = TRUE;
  1785. X      m_ptr = &m_list[c_ptr->cptr];
  1786. X      r_ptr = &c_list[m_ptr->mptr];
  1787. X      monster_name (m_name, m_ptr, r_ptr);
  1788. X      if (spd > 0)
  1789. X        {
  1790. X          m_ptr->cspeed += spd;
  1791. X          m_ptr->csleep = 0;
  1792. X          (void) sprintf (out_val, "%s starts moving faster.", m_name);
  1793. X          msg_print (out_val);
  1794. X          speed = TRUE;
  1795. X        }
  1796. X      else if (randint(MAX_MONS_LEVEL) > r_ptr->level)
  1797. X        {
  1798. X          m_ptr->cspeed += spd;
  1799. X          m_ptr->csleep = 0;
  1800. X          (void) sprintf (out_val, "%s starts moving slower.", m_name);
  1801. X          msg_print (out_val);
  1802. X          speed = TRUE;
  1803. X        }
  1804. X      else
  1805. X        {
  1806. X          m_ptr->csleep = 0;
  1807. X          (void) sprintf(out_val, "%s is unaffected.", m_name);
  1808. X          msg_print(out_val);
  1809. X        }
  1810. X    }
  1811. X    }
  1812. X  while (!flag);
  1813. X  return(speed);
  1814. X}
  1815. X
  1816. X
  1817. X/* Confuse a creature                    -RAK-    */
  1818. Xint confuse_monster(dir, y, x)
  1819. Xint dir, y, x;
  1820. X{
  1821. X  int flag, dist, confuse;
  1822. X  register cave_type *c_ptr;
  1823. X  register monster_type *m_ptr;
  1824. X  register creature_type *r_ptr;
  1825. X  vtype out_val, m_name;
  1826. X
  1827. X  confuse = FALSE;
  1828. X  flag = FALSE;
  1829. X  dist = 0;
  1830. X  do
  1831. X    {
  1832. X      (void) mmove(dir, &y, &x);
  1833. X      dist++;
  1834. X      c_ptr = &cave[y][x];
  1835. X      if ((dist > OBJ_BOLT_RANGE) || c_ptr->fval >= MIN_CLOSED_SPACE)
  1836. X    flag = TRUE;
  1837. X      else if (c_ptr->cptr > 1)
  1838. X    {
  1839. X      m_ptr = &m_list[c_ptr->cptr];
  1840. X      r_ptr = &c_list[m_ptr->mptr];
  1841. X      monster_name (m_name, m_ptr, r_ptr);
  1842. X      flag = TRUE;
  1843. X      if ((randint(MAX_MONS_LEVEL) < r_ptr->level) ||
  1844. X          (CD_NO_SLEEP & r_ptr->cdefense))
  1845. X        {
  1846. X          if (m_ptr->ml && (r_ptr->cdefense & CD_NO_SLEEP))
  1847. X        c_recall[m_ptr->mptr].r_cdefense |= CD_NO_SLEEP;
  1848. X          /* Monsters which resisted the attack should wake up.
  1849. X         Monsters with inane resistence ignore the attack.  */
  1850. X          if (! (CD_NO_SLEEP & r_ptr->cdefense))
  1851. X        m_ptr->csleep = 0;
  1852. X          (void) sprintf(out_val, "%s is unaffected.", m_name);
  1853. X          msg_print(out_val);
  1854. X        }
  1855. X      else
  1856. X        {
  1857. X          m_ptr->confused = TRUE;
  1858. X          confuse = TRUE;
  1859. X          m_ptr->csleep = 0;
  1860. X          (void) sprintf(out_val, "%s appears confused.", m_name);
  1861. X          msg_print(out_val);
  1862. X        }
  1863. X    }
  1864. END_OF_FILE
  1865. if test 31713 -ne `wc -c <'source/spells.c.1'`; then
  1866.     echo shar: \"'source/spells.c.1'\" unpacked with wrong size!
  1867. fi
  1868. # end of 'source/spells.c.1'
  1869. fi
  1870. if test -f 'util/mc/st.h' -a "${1}" != "-c" ; then 
  1871.   echo shar: Will not clobber existing file \"'util/mc/st.h'\"
  1872. else
  1873. echo shar: Extracting \"'util/mc/st.h'\" \(2080 characters\)
  1874. sed "s/^X//" >'util/mc/st.h' <<'END_OF_FILE'
  1875. X/* util/mc/st.h: definitions for the symbol table module
  1876. X *
  1877. X * Copyright (c) 1989 by Joseph Hall.
  1878. X * All rights reserved except as stated below.
  1879. X *
  1880. X * Jim Wilson and any other holders of copyright on substantial portions
  1881. X * of Moria are granted rights to use, modify, and distribute this program
  1882. X * as they see fit, so long as the terms of its use, modification and/or
  1883. X * distribution are no less restrictive than those applying to Moria,
  1884. X * version 5.0 or later, itself, and so long as this use is related to
  1885. X * the further development of Moria.
  1886. X *
  1887. X * Anyone having any other use in mind for this code should contact the
  1888. X * author at 4116 Brewster Dr., Raleigh NC 27606 (jnh@ecemwl.ncsu.edu).
  1889. X */
  1890. X
  1891. X#ifndef _ST_H_
  1892. X#define    _ST_H_
  1893. X
  1894. X#ifndef TRUE
  1895. X#define TRUE 1
  1896. X#endif
  1897. X
  1898. X#ifndef FALSE
  1899. X#define FALSE 0
  1900. X#endif
  1901. X
  1902. X/*
  1903. X * Needs generic_t
  1904. X */
  1905. X
  1906. X#include "generic.h"
  1907. X
  1908. X/*
  1909. X * maximum length of symbol strings
  1910. X */
  1911. X
  1912. X#define ST_MAX_SYM_LEN        32
  1913. X
  1914. X/*
  1915. X * Struct for individual entries
  1916. X */
  1917. X
  1918. Xtypedef    struct st_EntryStruct {
  1919. X
  1920. X    char    name[ST_MAX_SYM_LEN];    /* symbol string            */
  1921. X    int        type;            /* symbol type                */
  1922. X    struct st_EntryStruct *next_P;    /* next entry in chain            */
  1923. X    generic_t    gval;            /* symbol value                */
  1924. X
  1925. X} st_Entry_t, *st_Entry_Pt;
  1926. X
  1927. X/*
  1928. X * Struct for table header
  1929. X */
  1930. X
  1931. Xtypedef struct {
  1932. X
  1933. X    char    name[ST_MAX_SYM_LEN];
  1934. X                    /* table name                */
  1935. X    int        size,            /* size of table to be allocated        */
  1936. X        entryCt;        /* # of entries in table currently        */
  1937. X    st_Entry_Pt    *tab_A;            /* vector of ptrs to entries        */
  1938. X
  1939. X} st_Table_t, *st_Table_Pt;
  1940. X
  1941. X#define    ST_SYM_FOUND        0
  1942. X#define ST_OK            0
  1943. X#define ST_SYM_NOT_FOUND    1
  1944. X#define ST_NULL_TABLE        2
  1945. X
  1946. X#define ST_MAX_INPUT_LEN    256
  1947. X
  1948. X/*
  1949. X * functions defined in st_symtab.c
  1950. X */
  1951. X
  1952. Xextern st_Table_Pt St_NewTable();
  1953. Xextern void St_DelTable();
  1954. Xextern int St_GetSym();
  1955. Xextern int St_DefSym();
  1956. Xextern int St_ReplSym();
  1957. Xextern int St_DelSym();
  1958. Xextern st_Table_Pt St_GetTable();
  1959. Xextern void St_DumpTable();
  1960. Xextern char **St_ListTable();
  1961. Xextern char **St_SListTable();
  1962. Xextern int St_TableSize();
  1963. X
  1964. X#endif /* _ST_H_ */
  1965. X
  1966. END_OF_FILE
  1967. if test 2080 -ne `wc -c <'util/mc/st.h'`; then
  1968.     echo shar: \"'util/mc/st.h'\" unpacked with wrong size!
  1969. fi
  1970. # end of 'util/mc/st.h'
  1971. fi
  1972. echo shar: End of archive 18 \(of 39\).
  1973. cp /dev/null ark18isdone
  1974. MISSING=""
  1975. for I in 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 ; do
  1976.     if test ! -f ark${I}isdone ; then
  1977.     MISSING="${MISSING} ${I}"
  1978.     fi
  1979. done
  1980. if test "${MISSING}" = "" ; then
  1981.     echo You have unpacked all 39 archives.
  1982.     echo "Now run "bldfiles.sh" to build split files"
  1983.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1984. else
  1985.     echo You still need to unpack the following archives:
  1986.     echo "        " ${MISSING}
  1987. fi
  1988. ##  End of shell archive.
  1989. exit 0
  1990.