home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sources / games / 188 < prev    next >
Encoding:
Internet Message Format  |  1992-08-22  |  56.5 KB

  1. Path: sparky!uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i058:  umoria4 - single player dungeon simulation (ver. 5.5), Part26/39
  5. Message-ID: <3422@master.CNA.TEK.COM>
  6. Date: 22 Aug 92 22:13:27 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1705
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: grabiner@math.harvard.edu (David Grabiner)
  12. Posting-number: Volume 14, Issue 58
  13. Archive-name: umoria4/Part26
  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 26 (of 39)."
  26. # Contents:  OOChanges.2 source/misc1.c vms/moria.opt
  27. # Wrapped by billr@saab on Thu Aug 20 09:11:33 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'OOChanges.2' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'OOChanges.2'\"
  31. else
  32. echo shar: Extracting \"'OOChanges.2'\" \(28159 characters\)
  33. sed "s/^X//" >'OOChanges.2' <<'END_OF_FILE'
  34. Xseveral spelling errors in CJS code
  35. Xmisc1.c: forgot to change magic_treasure code when changed subvals a couple
  36. X    of days ago for wands/staffs/amulets/rings
  37. Xexterns.h, files.c, misc2.c, types.h: wrote new stat code, all stat bugs
  38. X    fixed now, 6 stat values now, get_dis_stat() eliminated, new function
  39. X    modify_stat(),
  40. Xmisc2.c: get_obj_num changed, to increase probability of getting higher
  41. X    level objects
  42. Xmisc1.c, treasur1.c: had to change gain stat bits, the low 6 order bits of
  43. X    treasure flags, because changed the order earlier
  44. X---------------- 10/11
  45. Xall: changed all 4 or less case switch statements except for one large one
  46. X    in generate.c to nested if statements, this is smaller and faster
  47. X---------------- 10/12
  48. Xdungeon.c, generate.c, moria1.c: new_spot moved from dungeon to generate
  49. X    because alloc_mon and place_win_mon use character position, fixed
  50. X    minor new_spot bug
  51. Xconstants.c, misc2.c, dungeon.c: bst_stat() can not call prt_stat, changed
  52. X    to set py.flags.status, new stat change flags defined, and stat
  53. X    print code added to dungeon.c
  54. Xcreature.c: many duplicate disturb/strcat/msg_print brought outside the
  55. X    switch statement in mon_cast_spell
  56. Xall: changed all unlite_spot() calls to lite_spot() calls, changed
  57. X    'if (test_light()) lite_spot()' code to just call lite_spot, this
  58. X    fixes many subtle bugs, mostly dealing with mon vis to infravision,
  59. X    unlite_spot code deleted
  60. Xfiles.c, misc2.c: added stat_adj(A_INT) to srh which was wrong
  61. Xmisc2.c, spells.c, moria1.c, types.h: id_stat() and hid_stat[] eliminated
  62. X    no more hidden stat values, display arg dropped from bst_stat()
  63. Xfiles.c, misc2.c: hex values replaced with constants
  64. X----------------- 10/14
  65. Xconstants.h, store1.c: increased store turn around from 4 (avg 2.5)
  66. X    to 9 (avg 5), changed store_main() to always call store create/destroy
  67. X    regardless of bounds, lowered values of bounds MIN and MAX
  68. X--------------- 10/18
  69. Xmoria2.c: when open chest, clear TR_CURSED flag, which just also happens to be
  70. X    monster win flag, to prevent easy wins
  71. Xconstants.h, misc1.c->wizard.c: replaced remaining hex magic numbers with
  72. X    manifest constants
  73. Xdungeon.c: added code that gives a player a chance of noticing that items
  74. X    in inventory/equipment list are magical, the chance is much higher
  75. X    for warriors than for magi
  76. X--------------- 10/19
  77. Xdungeon.c: ^P^P did not clear the line with the pause_line message
  78. Xmisc2.c: prt_state() did not clear all 3 digits of repeat counts
  79. Xall: moved lots of procedures around to increase number of static fuctions,
  80. X    also made sure every C file less than 60K
  81. Xcreate.c, extern.h, misc2.c, spells.c, variables.c: change way that mhp
  82. X    are calculated, new function calc_hitpoints(), new array player_hp[]
  83. X    which contains player mhp for each level
  84. Xextern.h, main.c, misc2.c, potions.c, spells.c: change way that cmana are
  85. X    calculated, new function calc_mana(), called whenever gain level,
  86. X    lose level, or learn/forget spells
  87. Xextern.h, main.c, misc2.c, spells.c: change the way that spells are learned
  88. X    and lost, learn_spell/learn_prayer deleted, new function calc_spells,
  89. X    new spell type state forgotten, new var spell_forgotten, etc.
  90. X-------------------- 10/20
  91. Xmonsters.c: made spirit troll into 'G', made invisible, pickup, carrys obj,
  92. X    added drain wisdom attack, added drain intelligence attack to green
  93. X    glutton ghost
  94. Xall: moved all msg_print(NULL) calls into io.c, specifically, clear_screen(),
  95. X    erase_line() and prt()
  96. Xmoria2.c, spells.c: two places that called test_light to see if monster or
  97. X    moving object lit were wrong, changed to eliminate check of fm
  98. Xcreature.c: update_mon() failed when hallucinating, changed print(cchar,...)
  99. X    to lite_spot() call
  100. Xvariables.c: adjusted call stat adjustments, mainly to make priest harder,
  101. X    gave priest negative str adjust, inc expfact from 10% to 20%
  102. Xmisc2.c: new funcs prt_int() and prt_long(), same as prt_num/prt_lnum()
  103. X    except no string argument, ": " moved into prt_num/prt_lnum string
  104. Xspells.c: all wands now have limits on range
  105. Xmonsters.c: doubled Balrog eye sight from 20->40, evil iggy from 20->30
  106. Xeat.c: increase hp gain for 22/23/24, increase hp loss for 27
  107. Xconstant.c, eat.c, potions.c, scrolls.c, staffs.c, treasur2.c wands.c:
  108. X    eliminate store bought flag, only gain exp when use an item if the
  109. X    use identifies the item
  110. X----------------- 10/23
  111. Xmagic.c, wands.c: spell/wand damage did not match
  112. Xcreature.c: monster stuck door bashing got sign of i_ptr->p1 wrong
  113. Xrecall.c: change corrosive gases to poison gases
  114. Xexterns.h, moria1.c: draw_block(), minmax(), maxmin() deleted, minmax and
  115. X    maxmin calls were unnecessary, draw_block only called from one
  116. X    place, sub2_move_light combined with sub1_move_light,
  117. X    sub4_move_light combined with sub3_move_light,
  118. Xcreature.c: fix mon_move() so that creatures that never move increment their
  119. X    r_attack[0] when standing next to the player, for Quylthulgs
  120. Xspells.c: detect object and detect treasure set tl, which could also light up
  121. X    monsters, they now set fm
  122. X----------------- 10/24
  123. Xspells.c: can not gain exp by disarming traps created by a scroll
  124. Xtypes.h, magic.c, prayer.c, variable.c, misc2.c, constant.h: removed sname
  125. X    from spell_type since it was a trivial value, changed sexp from 16
  126. X    bits to 8 by dividing value by 4, saves about 310 bytes
  127. Xmany files: eliminated long stretches of blanks in strings, remove repeated
  128. X    chars from strings, typically " : ", saves over 1K of data size
  129. X--------------- 10/25
  130. Xspells.c: aiming a ball type wand/spell at a 1-thick wall resulted in damage
  131. X    to creatures on the other side of the wall, now it doesn't
  132. Xmisc2.c: inc_stat changed so that player gains 1/6 to 1/3 of the distance
  133. X    from the max 18/100 stat, 0 to 100 takes 13 gain stat potions,
  134. X    dec_stat changed so that player loses 1/4 to 1/2 of the distance
  135. X    from the max 18/100 stat, 100 to 0 takes 13 lose stat potions
  136. Xmisc2.c: print_spells() modified so that spell are always listed with the
  137. X    same letter, i.e. the letter does not depend on whether or not
  138. X    you know the spells that precede it
  139. X--------------- 10/26
  140. Xdeath.c: day string was size 11 should be 12
  141. Xdungeon.c: make 'magik' detect same chance for each class, need to set
  142. X    i_ptr = &inventory[INVEN_LIGHT] before testing player_light,
  143. X    this could cause the light to go off permanently
  144. Xmisc2.c: calc_mana and calc_spells use p_prt->lev - class[].first_spell_lev-1
  145. X    instead of just the player lev
  146. Xtypes.h, variable.c: add new field to class info, first level in which the
  147. X    player can learn a spell, used immediately above
  148. Xvariable.c: green glutton ghost no longer drains int
  149. Xmisc2.c: print 'welcome to level message' before learning spells
  150. X--------------- 10/28
  151. Xconfig.h, externs.h, dungeon.c, wizard.c: version info put in a help file,
  152. X    game_version() function deleted
  153. Xfiles.c: removed obsolete print_map() and print_monster() code
  154. Xtreasur1.c: made ring of WOE decrease wisdom, to balance ring of stupidity,
  155. X    removed trailing ^ secret symbols which made no sense, changed
  156. X    constant values from known2 to known1, such as ring of lordly protect
  157. X    armor class values
  158. Xstore1.c, store2.c, externs.h, types.h: add storenice feature by Dan Berstein,
  159. X    if (good bargain > 3 * bad bagains + 20) then always get final price
  160. X    in that store, two new functions, noneedtobargain() and updatebargain()
  161. Xmoria1.c: fixed wear command so that it prints inven letter of item removed,
  162. X    and equip letter of item worn, added extra param to remove()
  163. Xgenerate.c, moria1.c, moria2.c, types.h: added an 'lr' flag to cave_type,
  164. X    this is set for every space in or next to a room, lr is true for
  165. X    lit rooms, and false for dark rooms, find_light() function deleted
  166. X    as it was no longer necessary, twall lights spots that have lr set
  167. Xmoria1.c, moria2.c: decrease search chances if hallucinating, decrease
  168. X    disarm chances if hallucinating, look fails completely
  169. Xeat.c: print message "You feel drugged." for mushroom of hallucination
  170. Xmoria1.c: eliminate unnecessary in_bounds() calls
  171. Xio.c: check to make sure tabs are all 8 character apart
  172. Xtreasur2.c: made object_ident array bss
  173. Xmisc2.c, moria1.c: fix calc_bonuses() so that it when wielding heavy bonuses,
  174. X    it subtracts the weight penalty from dis_th (display to hit),
  175. X    check_strength() modified to call calc_bonuses()
  176. Xmisc1.c: fixed compact_objects() and compact_monster() so that they update
  177. X    screen when deleting objects/monsters
  178. Xcreature.c, spells.c: put message in aggravate_monster(), took out redundant
  179. X    mesasge in creature.c
  180. Xmoria2.c: modify py_attack(), inven_throw() and py_bash() to make it more
  181. X    difficult to hit monsters which are not lit
  182. X---------------- 10/31
  183. Xmoria1.c: sub3_move_light() modified so that it does not print @ when in find
  184. X    mode
  185. Xrecall.c: had an 'i == 11 | i == 18' which should have been a ||
  186. X    printed out 11st,12nd,13rd levels incorrectly, now uses 'th'
  187. Xmoria1.c: fix see_wall, it assumed walls are # which is not true for PC/Atari
  188. Xspells.c: breath() could do damage on the other side of walls, added an los()
  189. X    call to prevent this
  190. Xmoria1.c: area_affect treated 'potential corner' and 'branching side corridor'
  191. X    identically, which is wrong, added see_nothing() so that these could
  192. X    be handled separately
  193. X---------------------- 11/1
  194. Xmoria1.c: when wearing object and must remove current object, fix code to
  195. X    use inven_check_num to see it is possible; in wear code, when remove
  196. X    old object check to see if inven_ctr increases before actually
  197. X    increasing wear_high
  198. Xconstants.h, misc2.c, moria1.c, store1.c, store2.c, treasure1.c, treasure2.c:
  199. X    change definition of subval 192 so it can be used for torches, it
  200. X    only stacks with others if have same p1 value, but it is always
  201. X    treated as a single object, change ITEM_* definitions in constant.h
  202. X    to match new definition, fix all code fragments that test subvals
  203. Xdesc.c: change to use new ITEM_ definition
  204. Xmoria1.c: fixed the potential corner/corridor intersection bug in the find
  205. X    code again, except this time it works better than the original code
  206. X------------------------------ 11/3
  207. Xvariables.c: decrease priestly HP bonus from 3 to 2
  208. Xmoria1.c: fixed wear code bug, called inven_check_num() with item not slot
  209. X----------------- 11/4
  210. Xmoria2.c: in tunnel(), print message if player tries to dig with hands
  211. Xmoria2.c: several places where object/treasure picked up did not clear
  212. X    c_ptr->fm, this is necessary since it might be set by detect spell
  213. X--------------- 11/7
  214. Xmoria1.c: fixed find_init so that moves straight into a corner would
  215. X    correctly run around the corner
  216. Xmoria1.c: changed the examine potential corner code in area_affect(), it
  217. X    would run into rooms if corridor entrance next to a wall, at least
  218. X    it doesn't do that for lighted rooms anymore
  219. X----------------- 11/8
  220. Xprayer.c: in remove curse spell, only clear flag for items that are
  221. X    wielded or worn
  222. Xio.c: truncate strings at col 79 instead of 80 if BUGGY_CURSES defined
  223. Xmoria1.c: print weights in show_inven and show_equip at col 71 not 72
  224. Xio.c, misc1.c, moria1.c: change highlight mode for walls to display '%'
  225. X    instead, this is much more portable that original code that used
  226. X    standout mode and the high character bit, changed print(),loc_symbol(),
  227. X    and see_wall()
  228. Xhelp.c: change help documentation for % character
  229. Xwizard.c: modify wizard_create and change_character functions, add whitespace,
  230. X    exit if get_string fails (i.e. typing ESCAPE exits), modify get_string
  231. X    limits to more reasonable values, remove switch for setting tchar
  232. Xmoria_wiz_help, moria_owiz_help: correct errors in command list
  233. Xdeath.c: add msg_print(NULL) after show_inven() in print_tomb() so that
  234. X    inventory can't    accidentally scroll of screen before exiting
  235. Xcreature.c, moria2.c, spells.c: can't call prt_experience() in mon_take_hit()
  236. X    as this gives "new level" message before "killed monster", move prt_exp
  237. X    calls to after msg_print at everyplace that calls mon_take_hit()
  238. Xdungeon.c: modified repeat count code so that can edit the number entered
  239. X    leave cursor on msg line while entering repeat count
  240. Xmoria2.c: change summon_object() so that it will only create objects within
  241. X    los of point where monster dies
  242. X--------------- 11/9
  243. Xstore1.c: stacking code in store_check_num() and store_carry() did not
  244. X    handle torches correctly, changed to be the same as inven_check_num
  245. X    code in moria2.c
  246. Xwizard.c: fixed mistake in change_character(), put *tmp_str != '\0' test
  247. X    in inside if statement, not outside one
  248. Xexterns.h, misc2.c, moria2.c: fix printing of spell characters from get_spell,
  249. X    print_spells changed consec TRUE to nonconsec == -1 for consecutive
  250. X    case, otherwise spells start with nonconsec=='a', added new arg to
  251. X    get_spells() first_spell which becomes nonconsec when call print_spell
  252. Xwizard.c: move 'gold' from end of change_character to right after 'mana'
  253. X    since it is more frequently used than the rest
  254. Xmisc2.c: alloc_object(), fix it so that objects are not created underneath
  255. X    the player, this was a problem for rubble and traps
  256. Xmisc1.c: allow sling ammo to be enchanted in magic_treasure()
  257. Xstore1.c: fix search_list() call for ammo in item_value(), was passing 1 ?!?
  258. X    instead of correct subval
  259. Xtreasur2.c: subval for spike wrong, change from 192 to 193
  260. Xmisc1.c: remove see invisible from slay monster arrows, since it doesn't make
  261. X    sense
  262. Xvariable.c: change blows_table entry for STR/W .5-.7 and DEX 10-18 from one
  263. X    to two, the value of one made things too difficult for low level mages
  264. Xmonsters.c: for all monsters which used to be sleep value of 1 (old style),
  265. X    change their new style sleep values from 0 to 1
  266. Xrecall.c: stupid typo, change CM_CARRY_OBJ|CM_CARRY_OBJ to ..OBJ|CM_CARRY_GOLD
  267. X---------------- 11/10
  268. Xmoria2.c: disarm() had signs switched for trap chances, "tot - 100 + level"
  269. X    changed to "tot + 100 - level"
  270. Xvariable.c: change "tin plated" to "tin-plated" and etc.
  271. X----------------- 11/13
  272. Xsave.c: changes to get the save code working again
  273. Xmoria2.c: when move onto a trap, instead of restoring confused count, should
  274. X    increment it by the old value, since the trap may have set it
  275. Xgenerate.c: for type 2 rooms, make them dark below level 25, not 30
  276. Xmoria2.c: when close a door, print "Something" instead of monster name if
  277. X    the monster blocking the door is invisible
  278. Xmoria2.c: in tunnel(), make the digging chance for non digging weapons equal
  279. X    to their max damage + tohit bonus instead of proportional to weight,
  280. X    the old code made lances better for digging than shovels
  281. Xmoria2.c: change py_bash() chance, make it a function of monster hp +
  282. X    monsters average max hp instead of level
  283. X--------------- 11/15
  284. Xsave.c, undef.c: restore_stats function eliminated, replaced by call to read
  285. X    py.stats from file, other fixes to get restore code working
  286. Xcreature.c: if creature never moves, kill it if it happens to be in a wall
  287. X    instead of moving it out of the wall
  288. Xgenerate.c: everywhere that TMP1_WALL is used, must also set fopen FALSE
  289. X    so that place_object(), vault_monster() etc will work correctly
  290. Xprayer.c: removed cure_blindness() and cure_confusion() from Holy Word spell,
  291. X    since could not pray while blind/confused
  292. Xsignals.c, io.c, externs.h: eliminate redundant definition of signal() in
  293. X    signals.c, also eliminate suspend_handler and assignment to it from
  294. X    signal(), make suspend() non-static
  295. Xmoria2.c: in look(), put blind and image tests before get_alldir()
  296. Xmoria2.c: in look() change [y to recall] to [(r)ecall]
  297. Xcreature.c, externs.h, generate.c, misc1.c, monsters.c, moria1.c, moria2.c,
  298. X    save.c, spells.c, types.h, constant.h: change m_list from linked list
  299. X    to a linear list, muptr deleted, monster_type nptr field deleted,
  300. X    function pushm deleted, now all scans of m_list go from mfptr (which
  301. X    always points at last element) to MON_MINIX == 2
  302. Xmisc1.c: compact_monster no longer calls prt_map(), which is unnecessary
  303. X--------------- 11/16
  304. Xeat.c: fixed restore charisma mushroom, print 'stops' instead of 'starts'
  305. Xmoria2.c: fix calculation of avg_max_hp in py_bash(), didn't check CD_MAX_HP
  306. Xmonsters.c: spirit troll too hard to hit when can't be seen, lower AC 56->40
  307. Xtreasure2.c: fixed scare_monster trap, the subtype value was wrong 63->99,
  308. X    and the level needed 100 added to it
  309. Xmisc2.: fix get_spells(), must add first_spell to *sn instead of subtracting
  310. X    from spell[i]
  311. Xcreature.c: in mon_move, return immediately if creature is killed because it
  312. X    is in rock
  313. X---------- 11/17
  314. Xexterns.h, spells.c, scrolls.c, prayer.c, staffs.c: change dispell_creature()
  315. X    to dispel_creature()
  316. Xspells.c: dispel_creature uses m_ptr->ml after calling mon_take_hit() which
  317. X    is wrong, now save value before calling mon_take_hit()
  318. Xmoria2.c: turn find_flag into a counter, when it reaches 100, exit find mode
  319. X    with message "You stop running to catch your breath.", prevents
  320. X    infinite loop
  321. Xgenerate.c: fixes to help prevent isolated rooms, in build_tunnel() make
  322. X    sure tunnel has gone at least 10 spaces from start before stop it,
  323. X    in cave_gen(), copy [yx]loc[0] to [yx]loc[k] so that can build tunnel
  324. X    from last room to first
  325. Xspells.c: light_line() called lower_monster_name() which is wrong, change
  326. X    to monster_name() call
  327. Xexterns.h, creature.c, moria2.c, spells.c: removed seen argument from
  328. X    mon_take_hit, as it was used inconsistently, only get credit for a
  329. X    kill if monster is visible when killed
  330. Xsave.c, dungeon.c: call disturb in save_char() to turn off searching and
  331. X    resting, remove search_off call in dungeon.c as is no longer needed
  332. Xvariable.c: remove initialized data for py and old_msg since were (mostly)
  333. X    zero, set f_ptr->food and f_ptr->food_digested in main.c
  334. Xconstant.h: delete some unused constants, rearrange the order of a few others
  335. X------------ 11/18
  336. Xvariables.c, externs.h, monsters.c, treasure2.c, save.c: every variable
  337. X    written to save file needs definate size, can not be just 'int',
  338. X    also spell_forgotten now read/written
  339. X-------------- 11/20
  340. Xspells.c: sleep_monsters1() did not set NO_SLEEP info for monster memory
  341. Xexterns.h, moria1.c: changed new_spot to accept short pointers since
  342. X    char_row and char_col are now shorts
  343. Xcreatures.c, spells.c: multiply_monster(), removed slp parameter since it was
  344. X    always FALSE, added monptr, to fix the m_list bug
  345. Xcreatures.c: new m_list code fails when call delete monster from within
  346. X    creatures(), fixed it by changing some calls to delete_monster()
  347. X    to call delete_monster() only if the dead monster is between the
  348. X    current monster and mfptr, otherwise, call fix1_delete_monster()
  349. Xexterns.h, creatures.c, spells.c: breath() has new argument monptr, to fix
  350. X    the m_list bug
  351. Xexterns.h, creatures.c, spells.c: two new functions, fix1_delete_monster()
  352. X    and fix2_delete_monster() which together equal delete_monster,
  353. X    these are called from within creatures() when a monster is killed
  354. Xmany: eliminate the fopen field since I had 5 bitfields in the cave structure,
  355. X    and it is much easier to only save 4, added a BLOCKED_CORR case for
  356. X    secret/closed/locked/stuck doors and rubble, all code that used
  357. X    to test fopen now tests fval, most code that used to set fopen is
  358. X    now gone since it was redundant with fval setting code
  359. Xmoria2.c: fixed disarm() so that if there is a valid trap to disarm, it will
  360. X    print "Something/monster_name is in the way!" just like close door."
  361. Xgenerate.c: place_stairs() could place them on the boundary, make sure
  362. X    that x/y can never be 0 or cur_xx-1, also, in town_gen(), call place_
  363. X    boundary() before place_stairs(), looks better, though not necessary
  364. Xmoria2.c: fixed openobject() so that if there is something to open, it will
  365. X    print an message just like closeobject if there is a monster in the way
  366. Xsave.c: fix another save file problem, noscorefile defined as int in get_char,
  367. X    just eliminated it and use noscore instead
  368. X--------------------------- 11/22
  369. Xmoria2.c: fix1_delete_monster() has to set m_ptr->hp to -1
  370. Xcreature.c: monster eating code checked monster exp wrong, was using cptr
  371. X    to index into the c_list
  372. Xcreature.c: in creatures(), call fix2_delete_monster if hp < 0
  373. Xmoria2.c, spells.c: dragon breath, wand bolts, wand balls, and thrown objects
  374. X    were visible even when blind, added checks, only print them if can see
  375. Xmoria2.c: tunnel(), print message "* is in the way" if there is a monster
  376. X    in the spot where the player is trying to tunnel
  377. X-------------- 11/23
  378. Xsave.c: player_hp was not saved/restored, total_winner and panic_save were not
  379. X    restored
  380. X------------- 11/27
  381. Xmoria2.c: in tunnel, add the weapon damage to its digging ability
  382. Xcreate.c: get_history(), clear the history strings before writing them with
  383. X    new values, to get rid of old strings
  384. Xvariable.c: for background strings, change "1st child" to "first child"
  385. Xstore2.c: add parameter to get_haggle() last_offer, in sell_haggle and
  386. X    purchase_haggle must set new_offer to 0, in get_haggle only allow
  387. X    incremental bid if new_offer == last_offer, i.e. at least one previous
  388. X    bid has been made
  389. Xdungeon.c: in main loop, call creatures(FALSE) to light/unlight creatures
  390. X    when ever player_light value changes
  391. X---------- 11/28
  392. Xsave.c: new save code, to reduce size of save file, and to make the savefiles
  393. X    portable
  394. Xconstant.h, desc.c, generate.c, misc1.c, misc2.c, moria2.c, save.c:
  395. X    changed the t_list from a linked list into a linear array of entries,
  396. X    just like the previous m_list change, new constant MIN_TRIX,
  397. X    all pusht calls changed to delete_object where ever appropriate, etc.
  398. X---------- 11/29
  399. Xmisc1.c: increase p1 value for crowns of seeing by multiplying by 5
  400. X----------- 12/4
  401. Xcreatures.c: change stealth code, instead of randint(10) < stl, it now cubes
  402. X    randint(64) and compares against 1 << (17 - stl), the result is that
  403. X    a change of one in stl always decreases monster notice chance by 80%,
  404. X    and perfect stealth is impossible
  405. Xwizard.c: allow wizard to enter any stealth between -1 and 17
  406. Xsave.c: extensive changes to save code competed, save files are now xor
  407. X    encrypted, and are supposedly portable, all savefile protection code
  408. X    is gone
  409. X---------- 12/5
  410. Xsave.c, undef.c, misc1.c: fix a few lint errors
  411. Xchanged version number to 5.0.8 and release the sources
  412. Xcreature.c: changed stealth code, amount monster woken by from 100 to 125
  413. X    (used to be 75 before 12/4)
  414. X-------- 12/6
  415. Xspells.c, creature.c: changed the way wall building wands work again,
  416. X    kill creature if it never moves, otherwise do a little damage,
  417. X    if creature can not move out of rock in mon_move, then do more damage
  418. X    and remove the wall ontop of the creature
  419. Xvarious: check use of "?", especially in get_check() and verify() prompts,
  420. X    verify changed to replace the period with a question mark
  421. Xspells.c, creature.c, misc1.c: breath(), update_mon(), and loc_symbol()
  422. X    changed to use blind status bit instead of blind counter, this
  423. X    helps make the display look better, i.e. nothing disappears until
  424. X    blindness takes affect in dungeon.c
  425. Xmonsters.c: more monster fixes from DJG
  426. Xmonsters.c, misc1.c, moria2.c, treasur1.c: change (SM) to (SA),
  427. X    slay monster to slay animal
  428. Xmonsters.c: set the new 'animal' bit correctly for all monsters
  429. Xrecall.c: change 'unnatural creature' to 'natural creature', change a few
  430. X    constants to defines
  431. Xsave.c: add error exits to every loop/array index in the get_char()
  432. X    routine to prevent crashes due to bad save files
  433. Xstore1.c: in item_value, set value to zero if known cursed, this prevents
  434. X    store from buying known cursed items
  435. X------------ 12/7
  436. Xstore2.c: remove switches in prt_comment*() functions, replace with table
  437. X    look up to get proper string, saves much code space
  438. Xcreature.c: changed stealth code again, if resting/paralyzed monster has a
  439. X    chance of noticing once every 50 turns instead of never like before,
  440. X    change 64 to 1024, and 17 to 29 for a better distribution
  441. Xconstant.h, save.c: read noscore variable from savefile of dead character, now
  442. X    only read/write noscore for live characters, changed patch_level to
  443. X    9 so that old savefiles can still be read
  444. Xsave.c: in get_char(), the loop error prevention code was missing two gotos
  445. Xstore2.c: get_haggle(), when check for valid first use of incremental haggle,
  446. X    ignore leading spaces in the string
  447. Xmoria2.c: add_food() should increment slow value, not just set it when bloated
  448. Xsave.c: when can't create savefile, test for from_savefile before giving
  449. X    wizard message "Overwrite old?", when exit in wizard mode do the
  450. X    "readable to all?" check after closing the file
  451. Xsave.c: from_savefile set wrong, should always be set if have read from a file
  452. X    not just when a complete character is read
  453. Xmoria2.c: bash(), do not put character off balance if bash is successful
  454. Xmisc2.c: get_spell(), instead of beeping for unknown spell, print a message
  455. Xrecall.c: for monsters with sleep value of 0, could never learn that fact,
  456. X    change it so that this will be known if have killed 10 of them
  457. X-----12/9
  458. Xdungeon.c: call disturb when player takes poison damage, or starvation
  459. X    damage
  460. Xvariable.c: change the three doors from 'a ...' to '& ...', needed because
  461. X    of wall-to-mud wand
  462. Xwizard.c: create_object wrong, was calling popt() then delete_object() then
  463. X    setting c_ptr->tptr, this fails because the delete objects will move
  464. X    the location (in t_list) of the just created object will change
  465. Xtreasur2.c: change 'nothing' item to be stackable, so that it can be safely
  466. X    picked up
  467. Xsave.c: was calling store_maint before objects were reidentified, this caused
  468. X    stores to end up with multple entries for stackable identified items
  469. Xexterns.h, misc2.c: new function inven_check_weight(), check toosee whether
  470. X    picking up an object will change the players speed
  471. Xmoria2.c: carry(), if picking up an object would slow you down, prompt with
  472. X    question "Exceed your weight limit?" to give player a choice
  473. Xmoria2.c, misc1.c: only show rock types in look() if highlight_seams option
  474. X    is set, also change option text from "highlight" to "HL and notice"
  475. Xspells.c: in fire_bolt() and fire_ball(), set recall info if monster takes
  476. X    extra damage because of weakness or reduced damage because of breath,
  477. X    in dispel_creature() set EVIL/UNDEAD flag if creature hurt,
  478. X    in turn_undead() set UNDEAD if creature hurt, in drain_life() set
  479. X    CD_UNDEAD if creature not hurt
  480. Xrecall.c: "may carry one or two treasures" needs the plural, but the others
  481. X    remain singular/collective
  482. X------------- 12/11
  483. Xcreature.c: stealth value changed again from 125 to 100
  484. Xwizard.c, variable.c: change rogue base stealth from 4 to 5, let wizard set
  485. X    stealth to 18
  486. Xmonster.c: white worm mass sleep value from 10 to 1, crystal ooze 60 -> 1
  487. Xcreature.c: in drain mana spell, if r1 greater than cmana, then set r1
  488. X    equal to cmana to limit creature's hp gain
  489. Xrecall.c: when print out creature attacks, exit loop if i >= 4, caused
  490. X    problems for umber hulk, etc. which have 4 attacks
  491. Xstore1.c: instead of destroying all single stackable objects, only destroy
  492. X    one half on average (randint(number)), makes store 1 and 5 inventories
  493. X    look better, oil is much more common, identify a little more common
  494. Xtreasure2.c: accidentally change blank_treasure tval earlier, set tval
  495. X    back to 0, and set subval to 64
  496. Xstore1.c: change store_carry(), for group items, must update scost; for any
  497. X    stackable item, set ipos so that inventory will scroll to show it;
  498. X    let group items (except torches) stack over 24 since each group is
  499. X    created with a set number to begin with; ipos must be set to -1 at
  500. X    start not 0;
  501. Xstore2.c: store_sell(), pass a pointer to cur_top instead of just its value,
  502. X    if sold object not on the page shown, scroll to show the object
  503. X------------ 12/13
  504. Xrecall.c: only print out known attacks, i.e. check r_attack, change i to count
  505. X    from 0 to 3, fixes bug with knowdamage(), add variable j to count
  506. X    attacks actually printed out
  507. Xsave.c: put limit on number of times store inventory changed in get_char()
  508. Xstore2.c: rewrite incremental haggle code again, add new parameter 'num_offer'
  509. X    to receive_offer, change get_offer parm last_offer to num_offer, only
  510. X    allow inc haggle if num_offer != 0; must reset new_offer after
  511. X    rejected offer in recieve_offer and sell/purchase_haggle
  512. X------------ 12/14
  513. Xmisc2.c, lots: change way spell learning works, new command 'G'ain magic
  514. X    spells, new function gain_spells() in misc2.c formerly part of
  515. X    calc_spells(), new status flag PY_STUDY controls printing of 'Study'
  516. X    in status line, new field py.flags.new_spells number of spells can
  517. X    learn
  518. Xorigcmds.hlp, roglcmds.hlp: document the 'M'ap and 'G'ain magic commands
  519. Xvariables.c, potions.c: remove potion of learning as it is no longer useful
  520. END_OF_FILE
  521. if test 28159 -ne `wc -c <'OOChanges.2'`; then
  522.     echo shar: \"'OOChanges.2'\" unpacked with wrong size!
  523. fi
  524. # end of 'OOChanges.2'
  525. fi
  526. if test -f 'source/misc1.c' -a "${1}" != "-c" ; then 
  527.   echo shar: Will not clobber existing file \"'source/misc1.c'\"
  528. else
  529. echo shar: Extracting \"'source/misc1.c'\" \(24413 characters\)
  530. sed "s/^X//" >'source/misc1.c' <<'END_OF_FILE'
  531. X/* source/misc1.c: misc utility and initialization code, magic objects code
  532. X
  533. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  534. X
  535. X   This software may be copied and distributed for educational, research, and
  536. X   not for profit purposes provided that this copyright and statement are
  537. X   included in all such copies. */
  538. X
  539. X#include "config.h"
  540. X#include "constant.h"
  541. X#include "types.h"
  542. X#include "externs.h"
  543. X
  544. X#ifdef __TURBOC__
  545. X#include    <stdlib.h>
  546. X#endif
  547. X
  548. X#ifdef Pyramid
  549. X#include <sys/time.h>
  550. X#else
  551. X#include <time.h>
  552. X#endif
  553. X#if !defined(GEMDOS) && !defined(MAC) && !defined(AMIGA)
  554. X#ifndef VMS
  555. X#include <sys/types.h>
  556. X#else
  557. X#include <types.h>
  558. X#endif
  559. X#endif
  560. X
  561. X#if !defined(ATARIST_MWC) && !defined(MAC) && !defined(VMS) && !defined(AMIGA)
  562. Xlong time();
  563. X#endif
  564. Xstruct tm *localtime();
  565. X
  566. X#if defined(LINT_ARGS)
  567. Xstatic void compact_objects(void);
  568. X#endif
  569. X
  570. X
  571. X/* gets a new random seed for the random number generator */
  572. Xvoid init_seeds(seed)
  573. Xint32u seed;
  574. X{
  575. X  register int32u clock_var;
  576. X
  577. X  if (seed == 0)
  578. X#ifdef MAC
  579. X    clock_var = time((time_t *)0);
  580. X#else
  581. X    clock_var = time((long *)0);
  582. X#endif
  583. X  else
  584. X    clock_var = seed;
  585. X  randes_seed = (int32) clock_var;
  586. X
  587. X  clock_var += 8762;
  588. X  town_seed = (int32) clock_var;
  589. X
  590. X  clock_var += 113452L;
  591. X  set_rnd_seed(clock_var);
  592. X  /* make it a little more random */
  593. X  for (clock_var = randint(100); clock_var != 0; clock_var--)
  594. X    (void) rnd();
  595. X}
  596. X
  597. X/* holds the previous rnd state */
  598. Xstatic int32u old_seed;
  599. X
  600. X/* change to different random number generator state */
  601. Xvoid set_seed(seed)
  602. Xint32u seed;
  603. X{
  604. X  old_seed = get_rnd_seed ();
  605. X
  606. X  /* want reproducible state here */
  607. X  set_rnd_seed (seed);
  608. X}
  609. X
  610. X
  611. X/* restore the normal random generator state */
  612. Xvoid reset_seed()
  613. X{
  614. X  set_rnd_seed (old_seed);
  615. X}
  616. X
  617. X
  618. X/* Check the day-time strings to see if open        -RAK-    */
  619. Xint check_time()
  620. X{
  621. X#ifdef MORIA_HOU
  622. X  long clock_var;
  623. X  register struct tm *tp;
  624. X
  625. X#ifdef MAC
  626. X  clock_var = time((time_t *)0);
  627. X#else
  628. X  clock_var = time((long *)0);
  629. X#endif
  630. X  tp = localtime(&clock_var);
  631. X  if (days[tp->tm_wday][tp->tm_hour+4] == 'X')
  632. X    return TRUE;
  633. X  else
  634. X    return FALSE;
  635. X#else
  636. X  return TRUE;
  637. X#endif
  638. X}
  639. X
  640. X
  641. X/* Generates a random integer x where 1<=X<=MAXVAL    -RAK-    */
  642. Xint randint(maxval)
  643. Xint maxval;
  644. X{
  645. X  register long randval;
  646. X
  647. X  randval = rnd ();
  648. X  return ((int)(randval % maxval) + 1);
  649. X}
  650. X
  651. X/* Generates a random integer number of NORMAL distribution -RAK-*/
  652. Xint randnor(mean, stand)
  653. Xint mean, stand;
  654. X{
  655. X  register int tmp, offset, low, iindex, high;
  656. X
  657. X#if 0
  658. X  /* alternate randnor code, slower but much smaller since no table */
  659. X  /* 2 per 1,000,000 will be > 4*SD, max is 5*SD */
  660. X  tmp = damroll(8, 99);     /* mean 400, SD 81 */
  661. X  tmp = (tmp - 400) * stand / 81;
  662. X  return tmp + mean;
  663. X#endif
  664. X
  665. X  tmp = randint(MAX_SHORT);
  666. X
  667. X  /* off scale, assign random value between 4 and 5 times SD */
  668. X  if (tmp == MAX_SHORT)
  669. X    {
  670. X      offset = 4 * stand + randint(stand);
  671. X
  672. X      /* one half are negative */
  673. X      if (randint(2) == 1)
  674. X    offset = -offset;
  675. X
  676. X      return mean + offset;
  677. X    }
  678. X
  679. X  /* binary search normal normal_table to get index that matches tmp */
  680. X  /* this takes up to 8 iterations */
  681. X  low = 0;
  682. X  iindex = NORMAL_TABLE_SIZE >> 1;
  683. X  high = NORMAL_TABLE_SIZE;
  684. X  while (TRUE)
  685. X    {
  686. X      if ((normal_table[iindex] == tmp) || (high == (low+1)))
  687. X    break;
  688. X      if (normal_table[iindex] > tmp)
  689. X    {
  690. X      high = iindex;
  691. X      iindex = low + ((iindex - low) >> 1);
  692. X    }
  693. X      else
  694. X    {
  695. X      low = iindex;
  696. X      iindex = iindex + ((high - iindex) >> 1);
  697. X    }
  698. X    }
  699. X
  700. X  /* might end up one below target, check that here */
  701. X  if (normal_table[iindex] < tmp)
  702. X    iindex = iindex + 1;
  703. X
  704. X  /* normal_table is based on SD of 64, so adjust the index value here,
  705. X     round the half way case up */
  706. X  offset = ((stand * iindex) + (NORMAL_TABLE_SD >> 1)) / NORMAL_TABLE_SD;
  707. X
  708. X  /* one half should be negative */
  709. X  if (randint(2) == 1)
  710. X    offset = -offset;
  711. X
  712. X  return mean + offset;
  713. X}
  714. X
  715. X
  716. X/* Returns position of first set bit            -RAK-    */
  717. X/*     and clears that bit */
  718. Xint bit_pos(test)
  719. Xint32u *test;
  720. X{
  721. X  register int i;
  722. X  register int32u mask = 0x1;
  723. X
  724. X  for (i = 0; i < sizeof(*test)*8; i++) {
  725. X    if (*test & mask) {
  726. X      *test &= ~mask;
  727. X      return(i);
  728. X    }
  729. X    mask <<= 1;
  730. X  }
  731. X
  732. X  /* no one bits found */
  733. X  return(-1);
  734. X}
  735. X
  736. X/* Checks a co-ordinate for in bounds status        -RAK-    */
  737. Xint in_bounds(y, x)
  738. Xint y, x;
  739. X{
  740. X  if ((y > 0) && (y < cur_height-1) && (x > 0) && (x < cur_width-1))
  741. X    return(TRUE);
  742. X  else
  743. X    return(FALSE);
  744. X}
  745. X
  746. X
  747. X/* Calculates current boundaries                -RAK-    */
  748. Xvoid panel_bounds()
  749. X{
  750. X  panel_row_min = panel_row*(SCREEN_HEIGHT/2);
  751. X  panel_row_max = panel_row_min + SCREEN_HEIGHT - 1;
  752. X  panel_row_prt = panel_row_min - 1;
  753. X  panel_col_min = panel_col*(SCREEN_WIDTH/2);
  754. X  panel_col_max = panel_col_min + SCREEN_WIDTH - 1;
  755. X  panel_col_prt = panel_col_min - 13;
  756. X}
  757. X
  758. X
  759. X/* Given an row (y) and col (x), this routine detects  -RAK-    */
  760. X/* when a move off the screen has occurred and figures new borders.
  761. X   Force forcses the panel bounds to be recalculated, useful for 'W'here. */
  762. Xint get_panel(y, x, force)
  763. Xint y, x, force;
  764. X{
  765. X  register int prow, pcol;
  766. X  register int panel;
  767. X
  768. X  prow = panel_row;
  769. X  pcol = panel_col;
  770. X  if (force || (y < panel_row_min + 2) || (y > panel_row_max - 2))
  771. X    {
  772. X      prow = ((y - SCREEN_HEIGHT/4)/(SCREEN_HEIGHT/2));
  773. X      if (prow > max_panel_rows)
  774. X    prow = max_panel_rows;
  775. X      else if (prow < 0)
  776. X    prow = 0;
  777. X    }
  778. X  if (force || (x < panel_col_min + 3) || (x > panel_col_max - 3))
  779. X    {
  780. X      pcol = ((x - SCREEN_WIDTH/4)/(SCREEN_WIDTH/2));
  781. X      if (pcol > max_panel_cols)
  782. X    pcol = max_panel_cols;
  783. X      else if (pcol < 0)
  784. X    pcol = 0;
  785. X    }
  786. X  if ((prow != panel_row) || (pcol != panel_col))
  787. X    {
  788. X      panel_row = prow;
  789. X      panel_col = pcol;
  790. X      panel_bounds();
  791. X      panel = TRUE;
  792. X      /* stop movement if any */
  793. X      if (find_bound)
  794. X    end_find();
  795. X    }
  796. X  else
  797. X    panel = FALSE;
  798. X  return(panel);
  799. X}
  800. X
  801. X
  802. X/* Tests a given point to see if it is within the screen -RAK-    */
  803. X/* boundaries.                              */
  804. Xint panel_contains(y, x)
  805. Xregister int y, x;
  806. X{
  807. X  if ((y >= panel_row_min) && (y <= panel_row_max) &&
  808. X      (x >= panel_col_min) && (x <= panel_col_max))
  809. X    return (TRUE);
  810. X  else
  811. X    return (FALSE);
  812. X}
  813. X
  814. X
  815. X/* Distance between two points                -RAK-    */
  816. Xint distance(y1, x1, y2, x2)
  817. Xint y1, x1, y2, x2;
  818. X{
  819. X  register int dy, dx;
  820. X
  821. X  dy = y1 - y2;
  822. X  if (dy < 0)
  823. X    dy = -dy;
  824. X  dx = x1 - x2;
  825. X  if (dx < 0)
  826. X    dx = -dx;
  827. X
  828. X  return ((((dy + dx) << 1) - (dy > dx ? dx : dy)) >> 1);
  829. X}
  830. X
  831. X/* Checks points north, south, east, and west for a wall -RAK-    */
  832. X/* note that y,x is always in_bounds(), i.e. 0 < y < cur_height-1, and
  833. X   0 < x < cur_width-1    */
  834. Xint next_to_walls(y, x)
  835. Xregister int y, x;
  836. X{
  837. X  register int i;
  838. X  register cave_type *c_ptr;
  839. X
  840. X  i = 0;
  841. X  c_ptr = &cave[y-1][x];
  842. X  if (c_ptr->fval >= MIN_CAVE_WALL)
  843. X    i++;
  844. X  c_ptr = &cave[y+1][x];
  845. X  if (c_ptr->fval >= MIN_CAVE_WALL)
  846. X    i++;
  847. X  c_ptr = &cave[y][x-1];
  848. X  if (c_ptr->fval >= MIN_CAVE_WALL)
  849. X    i++;
  850. X  c_ptr = &cave[y][x+1];
  851. X  if (c_ptr->fval >= MIN_CAVE_WALL)
  852. X    i++;
  853. X
  854. X  return(i);
  855. X}
  856. X
  857. X
  858. X/* Checks all adjacent spots for corridors        -RAK-    */
  859. X/* note that y, x is always in_bounds(), hence no need to check that
  860. X   j, k are in_bounds(), even if they are 0 or cur_x-1 is still works */
  861. Xint next_to_corr(y, x)
  862. Xregister int y, x;
  863. X{
  864. X  register int k, j, i;
  865. X  register cave_type *c_ptr;
  866. X
  867. X  i = 0;
  868. X  for (j = y - 1; j <= (y + 1); j++)
  869. X    for (k = x - 1; k <= (x + 1); k++)
  870. X      {
  871. X    c_ptr = &cave[j][k];
  872. X    /* should fail if there is already a door present */
  873. X    if (c_ptr->fval == CORR_FLOOR
  874. X        && (c_ptr->tptr == 0 || t_list[c_ptr->tptr].tval < TV_MIN_DOORS))
  875. X      i++;
  876. X      }
  877. X  return(i);
  878. X}
  879. X
  880. X
  881. X/* generates damage for 2d6 style dice rolls */
  882. Xint damroll(num, sides)
  883. Xint num, sides;
  884. X{
  885. X  register int i, sum = 0;
  886. X
  887. X  for (i = 0; i < num; i++)
  888. X    sum += randint(sides);
  889. X  return(sum);
  890. X}
  891. X
  892. Xint pdamroll(array)
  893. Xint8u *array;
  894. X{
  895. X  return damroll((int)array[0], (int)array[1]);
  896. X}
  897. X
  898. X
  899. X/* A simple, fast, integer-based line-of-sight algorithm.  By Joseph Hall,
  900. X   4116 Brewster Drive, Raleigh NC 27606.  Email to jnh@ecemwl.ncsu.edu.
  901. X
  902. X   Returns TRUE if a line of sight can be traced from x0, y0 to x1, y1.
  903. X
  904. X   The LOS begins at the center of the tile [x0, y0] and ends at
  905. X   the center of the tile [x1, y1].  If los() is to return TRUE, all of
  906. X   the tiles this line passes through must be transparent, WITH THE
  907. X   EXCEPTIONS of the starting and ending tiles.
  908. X
  909. X   We don't consider the line to be "passing through" a tile if
  910. X   it only passes across one corner of that tile. */
  911. X
  912. X/* Because this function uses (short) ints for all calculations, overflow
  913. X   may occur if deltaX and deltaY exceed 90. */
  914. X
  915. Xint los(fromY, fromX, toY, toX)
  916. Xint fromY, fromX, toY, toX;
  917. X{
  918. X  register int tmp, deltaX, deltaY;
  919. X
  920. X  deltaX = toX - fromX;
  921. X  deltaY = toY - fromY;
  922. X
  923. X  /* Adjacent? */
  924. X  if ((deltaX < 2) && (deltaX > -2) && (deltaY < 2) && (deltaY > -2))
  925. X    return TRUE;
  926. X
  927. X  /* Handle the cases where deltaX or deltaY == 0. */
  928. X  if (deltaX == 0)
  929. X    {
  930. X      register int p_y;    /* y position -- loop variable    */
  931. X
  932. X      if (deltaY < 0)
  933. X    {
  934. X      tmp = fromY;
  935. X      fromY = toY;
  936. X      toY = tmp;
  937. X    }
  938. X      for (p_y = fromY + 1; p_y < toY; p_y++)
  939. X    if (cave[p_y][fromX].fval >= MIN_CLOSED_SPACE)
  940. X      return FALSE;
  941. X      return TRUE;
  942. X    }
  943. X  else if (deltaY == 0)
  944. X    {
  945. X      register int px;    /* x position -- loop variable    */
  946. X
  947. X      if (deltaX < 0)
  948. X    {
  949. X      tmp = fromX;
  950. X      fromX = toX;
  951. X      toX = tmp;
  952. X    }
  953. X      for (px = fromX + 1; px < toX; px++)
  954. X    if (cave[fromY][px].fval >= MIN_CLOSED_SPACE)
  955. X      return FALSE;
  956. X      return TRUE;
  957. X    }
  958. X
  959. X  /* Now, we've eliminated all the degenerate cases.
  960. X     In the computations below, dy (or dx) and m are multiplied by a
  961. X     scale factor, scale = abs(deltaX * deltaY * 2), so that we can use
  962. X     integer arithmetic. */
  963. X
  964. X  {
  965. X    register int px,    /* x position                */
  966. X     p_y,        /* y position                */
  967. X     scale2;        /* above scale factor / 2        */
  968. X    int scale,        /* above scale factor            */
  969. X     xSign,        /* sign of deltaX            */
  970. X     ySign,        /* sign of deltaY            */
  971. X     m;            /* slope or 1/slope of LOS        */
  972. X
  973. X    scale2 = abs(deltaX * deltaY);
  974. X    scale = scale2 << 1;
  975. X    xSign = (deltaX < 0) ? -1 : 1;
  976. X    ySign = (deltaY < 0) ? -1 : 1;
  977. X
  978. X    /* Travel from one end of the line to the other, oriented along
  979. X       the longer axis. */
  980. X
  981. X    if (abs(deltaX) >= abs(deltaY))
  982. X      {
  983. X    register int dy;        /* "fractional" y position    */
  984. X    /* We start at the border between the first and second tiles,
  985. X       where the y offset = .5 * slope.  Remember the scale
  986. X       factor.  We have:
  987. X
  988. X       m = deltaY / deltaX * 2 * (deltaY * deltaX)
  989. X         = 2 * deltaY * deltaY. */
  990. X
  991. X    dy = deltaY * deltaY;
  992. X    m = dy << 1;
  993. X    px = fromX + xSign;
  994. X
  995. X    /* Consider the special case where slope == 1. */
  996. X    if (dy == scale2)
  997. X      {
  998. X        p_y = fromY + ySign;
  999. X        dy -= scale;
  1000. X      }
  1001. X    else
  1002. X      p_y = fromY;
  1003. X
  1004. X    while (toX - px)
  1005. X      {
  1006. X        if (cave[p_y][px].fval >= MIN_CLOSED_SPACE)
  1007. X          return FALSE;
  1008. X
  1009. X        dy += m;
  1010. X        if (dy < scale2)
  1011. X          px += xSign;
  1012. X        else if (dy > scale2)
  1013. X          {
  1014. X        p_y += ySign;
  1015. X        if (cave[p_y][px].fval >= MIN_CLOSED_SPACE)
  1016. X          return FALSE;
  1017. X        px += xSign;
  1018. X        dy -= scale;
  1019. X          }
  1020. X        else
  1021. X          {
  1022. X        /* This is the case, dy == scale2, where the LOS
  1023. X           exactly meets the corner of a tile. */
  1024. X        px += xSign;
  1025. X        p_y += ySign;
  1026. X        dy -= scale;
  1027. X          }
  1028. X      }
  1029. X    return TRUE;
  1030. X      }
  1031. X    else
  1032. X      {
  1033. X    register int dx;        /* "fractional" x position    */
  1034. X    dx = deltaX * deltaX;
  1035. X    m = dx << 1;
  1036. X
  1037. X    p_y = fromY + ySign;
  1038. X    if (dx == scale2)
  1039. X      {
  1040. X        px = fromX + xSign;
  1041. X        dx -= scale;
  1042. X      }
  1043. X    else
  1044. X      px = fromX;
  1045. X
  1046. X    while (toY - p_y)
  1047. X      {
  1048. X        if (cave[p_y][px].fval >= MIN_CLOSED_SPACE)
  1049. X          return FALSE;
  1050. X        dx += m;
  1051. X        if (dx < scale2)
  1052. X          p_y += ySign;
  1053. X        else if (dx > scale2)
  1054. X          {
  1055. X        px += xSign;
  1056. X        if (cave[p_y][px].fval >= MIN_CLOSED_SPACE)
  1057. X          return FALSE;
  1058. X        p_y += ySign;
  1059. X        dx -= scale;
  1060. X          }
  1061. X        else
  1062. X          {
  1063. X        px += xSign;
  1064. X        p_y += ySign;
  1065. X        dx -= scale;
  1066. X          }
  1067. X      }
  1068. X    return TRUE;
  1069. X      }
  1070. X  }
  1071. X}
  1072. X
  1073. X
  1074. X/* Returns symbol for given row, column            -RAK-    */
  1075. Xunsigned char loc_symbol(y, x)
  1076. Xint y, x;
  1077. X{
  1078. X  register cave_type *cave_ptr;
  1079. X  register struct flags *f_ptr;
  1080. X
  1081. X  cave_ptr = &cave[y][x];
  1082. X  f_ptr = &py.flags;
  1083. X
  1084. X  if ((cave_ptr->cptr == 1) && (!find_flag || find_prself))
  1085. X    return '@';
  1086. X  else if (f_ptr->status & PY_BLIND)
  1087. X    return ' ';
  1088. X  else if ((f_ptr->image > 0) && (randint (12) == 1))
  1089. X    return randint (95) + 31;
  1090. X  else if ((cave_ptr->cptr > 1) && (m_list[cave_ptr->cptr].ml))
  1091. X    return c_list[m_list[cave_ptr->cptr].mptr].cchar;
  1092. X  else if (!cave_ptr->pl && !cave_ptr->tl && !cave_ptr->fm)
  1093. X    return ' ';
  1094. X  else if ((cave_ptr->tptr != 0)
  1095. X       && (t_list[cave_ptr->tptr].tval != TV_INVIS_TRAP))
  1096. X    return t_list[cave_ptr->tptr].tchar;
  1097. X  else if (cave_ptr->fval <= MAX_CAVE_FLOOR)
  1098. X    {
  1099. X#ifdef MSDOS
  1100. X      return floorsym;
  1101. X#else
  1102. X      return '.';
  1103. X#endif
  1104. X    }
  1105. X  else if (cave_ptr->fval == GRANITE_WALL || cave_ptr->fval == BOUNDARY_WALL
  1106. X       || highlight_seams == FALSE)
  1107. X    {
  1108. X#ifdef MSDOS
  1109. X      return wallsym;
  1110. X#else
  1111. X#ifndef ATARI_ST
  1112. X      return '#';
  1113. X#else
  1114. X      return (unsigned char)240;
  1115. X#endif
  1116. X#endif
  1117. X    }
  1118. X  else    /* Originally set highlight bit, but that is not portable, now use
  1119. X       the percent sign instead. */
  1120. X    {
  1121. X      return '%';
  1122. X    }
  1123. X}
  1124. X
  1125. X
  1126. X/* Tests a spot for light or field mark status        -RAK-    */
  1127. Xint test_light(y, x)
  1128. Xint y, x;
  1129. X{
  1130. X  register cave_type *cave_ptr;
  1131. X
  1132. X  cave_ptr = &cave[y][x];
  1133. X  if (cave_ptr->pl || cave_ptr->tl || cave_ptr->fm)
  1134. X    return(TRUE);
  1135. X  else
  1136. X    return(FALSE);
  1137. X}
  1138. X
  1139. X
  1140. X/* Prints the map of the dungeon            -RAK-    */
  1141. Xvoid prt_map()
  1142. X{
  1143. X  register int i, j, k;
  1144. X  register unsigned char tmp_char;
  1145. X
  1146. X  k = 0;
  1147. X  for (i = panel_row_min; i <= panel_row_max; i++)  /* Top to bottom */
  1148. X    {
  1149. X      k++;
  1150. X      erase_line (k, 13);
  1151. X      for (j = panel_col_min; j <= panel_col_max; j++)    /* Left to right */
  1152. X    {
  1153. X      tmp_char = loc_symbol(i, j);
  1154. X      if (tmp_char != ' ')
  1155. X        print(tmp_char, i, j);
  1156. X    }
  1157. X    }
  1158. X}
  1159. X
  1160. X
  1161. X/* Compact monsters                    -RAK-    */
  1162. X/* Return TRUE if any monsters were deleted, FALSE if could not delete any
  1163. X   monsters.  */
  1164. Xint compact_monsters()
  1165. X{
  1166. X  register int i;
  1167. X  int cur_dis, delete_any;
  1168. X  register monster_type *mon_ptr;
  1169. X#ifdef ATARIST_MWC
  1170. X  int32 holder;
  1171. X#endif
  1172. X
  1173. X  msg_print("Compacting monsters...");
  1174. X
  1175. X  cur_dis = 66;
  1176. X  delete_any = FALSE;
  1177. X  do
  1178. X    {
  1179. X      for (i = mfptr - 1; i >= MIN_MONIX; i--)
  1180. X    {
  1181. X      mon_ptr = &m_list[i];
  1182. X      if ((cur_dis < mon_ptr->cdis) && (randint(3) == 1))
  1183. X        {
  1184. X          /* Never compact away the Balrog!! */
  1185. X#ifdef ATARIST_MWC
  1186. X          if (c_list[mon_ptr->mptr].cmove & (holder = CM_WIN))
  1187. X#else
  1188. X          if (c_list[mon_ptr->mptr].cmove & CM_WIN)
  1189. X#endif
  1190. X        /* Do nothing */
  1191. X        ;
  1192. X          /* in case this is called from within creatures(), this is a
  1193. X         horrible hack, the m_list/creatures() code needs to be
  1194. X         rewritten */
  1195. X          else if (hack_monptr < i)
  1196. X        {
  1197. X          delete_monster(i);
  1198. X          delete_any = TRUE;
  1199. X        }
  1200. X          else
  1201. X        /* fix1_delete_monster() does not decrement mfptr, so
  1202. X           don't set delete_any if this was called */
  1203. X        fix1_delete_monster(i);
  1204. X        }
  1205. X    }
  1206. X      if (!delete_any)
  1207. X    {
  1208. X      cur_dis -= 6;
  1209. X      /* Can't delete any monsters, return failure.  */
  1210. X      if (cur_dis < 0)
  1211. X        return FALSE;
  1212. X    }
  1213. X    }
  1214. X  while (!delete_any);
  1215. X  return TRUE;
  1216. X}
  1217. X
  1218. X
  1219. X/* Add to the players food time                -RAK-    */
  1220. Xvoid add_food(num)
  1221. Xint num;
  1222. X{
  1223. X  register struct flags *p_ptr;
  1224. X  register int extra, penalty;
  1225. X
  1226. X  p_ptr = &py.flags;
  1227. X  if (p_ptr->food < 0)    p_ptr->food = 0;
  1228. X  p_ptr->food += num;
  1229. X  if (p_ptr->food > PLAYER_FOOD_MAX)
  1230. X    {
  1231. X      msg_print("You are bloated from overeating.");
  1232. X
  1233. X      /* Calculate how much of num is responsible for the bloating.
  1234. X     Give the player food credit for 1/50, and slow him for that many
  1235. X     turns also.  */
  1236. X      extra = p_ptr->food - PLAYER_FOOD_MAX;
  1237. X      if (extra > num)
  1238. X    extra = num;
  1239. X      penalty = extra / 50;
  1240. X
  1241. X      p_ptr->slow += penalty;
  1242. X      if (extra == num)
  1243. X    p_ptr->food = p_ptr->food - num + penalty;
  1244. X      else
  1245. X    p_ptr->food = PLAYER_FOOD_MAX + penalty;
  1246. X    }
  1247. X  else if (p_ptr->food > PLAYER_FOOD_FULL)
  1248. X    msg_print("You are full.");
  1249. X}
  1250. X
  1251. X
  1252. X/* Returns a pointer to next free space            -RAK-    */
  1253. X/* Returns -1 if could not allocate a monster.  */
  1254. Xint popm()
  1255. X{
  1256. X  if (mfptr == MAX_MALLOC)
  1257. X    {
  1258. X      if (! compact_monsters())
  1259. X    return -1;
  1260. X    }
  1261. X  return (mfptr++);
  1262. X}
  1263. X
  1264. X
  1265. X/* Gives Max hit points                    -RAK-    */
  1266. Xint max_hp(array)
  1267. Xint8u *array;
  1268. X{
  1269. X  return(array[0] * array[1]);
  1270. X}
  1271. X
  1272. X
  1273. X/* Places a monster at given location            -RAK-    */
  1274. Xint place_monster(y, x, z, slp)
  1275. Xregister int y, x, z;
  1276. Xint slp;
  1277. X{
  1278. X  register int cur_pos;
  1279. X  register monster_type *mon_ptr;
  1280. X
  1281. X  cur_pos = popm();
  1282. X  if (cur_pos == -1)
  1283. X    return FALSE;
  1284. X  mon_ptr = &m_list[cur_pos];
  1285. X  mon_ptr->fy = y;
  1286. X  mon_ptr->fx = x;
  1287. X  mon_ptr->mptr = z;
  1288. X  if (c_list[z].cdefense & CD_MAX_HP)
  1289. X    mon_ptr->hp = max_hp(c_list[z].hd);
  1290. X  else
  1291. X    mon_ptr->hp = pdamroll(c_list[z].hd);
  1292. X  /* the c_list speed value is 10 greater, so that it can be a int8u */
  1293. X  mon_ptr->cspeed = c_list[z].speed - 10 + py.flags.speed;
  1294. X  mon_ptr->stunned = 0;
  1295. X  mon_ptr->cdis = distance(char_row, char_col,y,x);
  1296. X  mon_ptr->ml = FALSE;
  1297. X  cave[y][x].cptr = cur_pos;
  1298. X  if (slp)
  1299. X    {
  1300. X      if (c_list[z].sleep == 0)
  1301. X    mon_ptr->csleep = 0;
  1302. X      else
  1303. X    mon_ptr->csleep = (c_list[z].sleep * 2) +
  1304. X      randint((int)c_list[z].sleep*10);
  1305. X    }
  1306. X  else
  1307. X    mon_ptr->csleep = 0;
  1308. X  return TRUE;
  1309. X}
  1310. X
  1311. X
  1312. X/* Places a monster at given location            -RAK-    */
  1313. Xvoid place_win_monster()
  1314. X{
  1315. X  register int y, x, cur_pos;
  1316. X  register monster_type *mon_ptr;
  1317. X
  1318. X  if (!total_winner)
  1319. X    {
  1320. X      cur_pos = popm();
  1321. X      /* Check for case where could not allocate space for the win monster,
  1322. X     this should never happen.  */
  1323. X      if (cur_pos == -1)
  1324. X    abort();
  1325. X      mon_ptr = &m_list[cur_pos];
  1326. X      do
  1327. X    {
  1328. X      y = randint(cur_height-2);
  1329. X      x = randint(cur_width-2);
  1330. X    }
  1331. X      while ((cave[y][x].fval >= MIN_CLOSED_SPACE) || (cave[y][x].cptr != 0)
  1332. X         || (cave[y][x].tptr != 0) ||
  1333. X          (distance(y,x,char_row, char_col) <= MAX_SIGHT));
  1334. X      mon_ptr->fy = y;
  1335. X      mon_ptr->fx = x;
  1336. X      mon_ptr->mptr = randint(WIN_MON_TOT) - 1 + m_level[MAX_MONS_LEVEL];
  1337. X      if (c_list[mon_ptr->mptr].cdefense & CD_MAX_HP)
  1338. X    mon_ptr->hp = max_hp(c_list[mon_ptr->mptr].hd);
  1339. X      else
  1340. X    mon_ptr->hp = pdamroll(c_list[mon_ptr->mptr].hd);
  1341. X      /* the c_list speed value is 10 greater, so that it can be a int8u */
  1342. X      mon_ptr->cspeed = c_list[mon_ptr->mptr].speed - 10 + py.flags.speed;
  1343. X      mon_ptr->stunned = 0;
  1344. X      mon_ptr->cdis = distance(char_row, char_col,y,x);
  1345. X      cave[y][x].cptr = cur_pos;
  1346. X      mon_ptr->csleep = 0;
  1347. X    }
  1348. X}
  1349. X
  1350. X
  1351. X/* Return a monster suitable to be placed at a given level.  This makes
  1352. X   high level monsters (up to the given level) slightly more common than
  1353. X   low level monsters at any given level.   -CJS- */
  1354. Xint get_mons_num (level)
  1355. Xint level;
  1356. X{
  1357. X  register int i, j, num;
  1358. X
  1359. X  if (level == 0)
  1360. X    i = randint (m_level[0]) - 1;
  1361. X  else
  1362. X    {
  1363. X      if (level > MAX_MONS_LEVEL)
  1364. X    level = MAX_MONS_LEVEL;
  1365. X      if (randint (MON_NASTY) == 1)
  1366. X    {
  1367. X      i = randnor (0, 4);
  1368. X      level = level + abs(i) + 1;
  1369. X      if (level > MAX_MONS_LEVEL)
  1370. X        level = MAX_MONS_LEVEL;
  1371. X    }
  1372. X      else
  1373. X    {
  1374. X      /* This code has been added to make it slightly more likely to
  1375. X         get the higher level monsters. Originally a uniform
  1376. X         distribution over all monsters of level less than or equal to the
  1377. X         dungeon level. This distribution makes a level n monster occur
  1378. X         approx 2/n% of the time on level n, and 1/n*n% are 1st level. */
  1379. X
  1380. X      num = m_level[level] - m_level[0];
  1381. X      i = randint (num) - 1;
  1382. X      j = randint (num) - 1;
  1383. X      if (j > i)
  1384. X        i = j;
  1385. X      level = c_list[i + m_level[0]].level;
  1386. X    }
  1387. X      i = randint(m_level[level]-m_level[level-1]) - 1 + m_level[level-1];
  1388. X    }
  1389. X  return i;
  1390. X}
  1391. X
  1392. X
  1393. X/* Allocates a random monster                -RAK-    */
  1394. Xvoid alloc_monster(num, dis, slp)
  1395. Xint num, dis;
  1396. Xint slp;
  1397. X{
  1398. X  register int y, x, i;
  1399. X  int l;
  1400. X
  1401. X  for (i = 0; i < num; i++)
  1402. X    {
  1403. X      do
  1404. X    {
  1405. X      y = randint(cur_height-2);
  1406. X      x = randint(cur_width-2);
  1407. X    }
  1408. X      while (cave[y][x].fval >= MIN_CLOSED_SPACE || (cave[y][x].cptr != 0) ||
  1409. X         (distance(y, x, char_row, char_col) <= dis));
  1410. X
  1411. X      l = get_mons_num (dun_level);
  1412. X      /* Dragons are always created sleeping here, so as to give the player a
  1413. X     sporting chance.  */
  1414. X      if (c_list[l].cchar == 'd' || c_list[l].cchar == 'D')
  1415. X    slp = TRUE;
  1416. X      /* Place_monster() should always return TRUE here.  It does not
  1417. X     matter if it fails though.  */
  1418. X      (void) place_monster(y, x, l, slp);
  1419. X    }
  1420. X}
  1421. X
  1422. X
  1423. X/* Places creature adjacent to given location        -RAK-    */
  1424. Xint summon_monster(y, x, slp)
  1425. Xint *y, *x;
  1426. Xint slp;
  1427. X{
  1428. X  register int i, j, k;
  1429. X  int l, summon;
  1430. X  register cave_type *cave_ptr;
  1431. X
  1432. X  i = 0;
  1433. X  summon = FALSE;
  1434. X  l = get_mons_num (dun_level + MON_SUMMON_ADJ);
  1435. X  do
  1436. X    {
  1437. X      j = *y - 2 + randint(3);
  1438. X      k = *x - 2 + randint(3);
  1439. X      if (in_bounds(j, k))
  1440. X    {
  1441. X      cave_ptr = &cave[j][k];
  1442. X      if (cave_ptr->fval <= MAX_OPEN_SPACE && (cave_ptr->cptr == 0))
  1443. X        {
  1444. X          /* Place_monster() should always return TRUE here.  */
  1445. X          if (!place_monster(j, k, l, slp))
  1446. X        return FALSE;
  1447. X          summon = TRUE;
  1448. X          i = 9;
  1449. X          *y = j;
  1450. X          *x = k;
  1451. X        }
  1452. X    }
  1453. X      i++;
  1454. X    }
  1455. X  while (i <= 9);
  1456. X  return(summon);
  1457. X}
  1458. X
  1459. X
  1460. X/* Places undead adjacent to given location        -RAK-    */
  1461. Xint summon_undead(y, x)
  1462. Xint *y, *x;
  1463. X{
  1464. X  register int i, j, k;
  1465. X  int l, m, ctr, summon;
  1466. X  register cave_type *cave_ptr;
  1467. X
  1468. X  i = 0;
  1469. X  summon = FALSE;
  1470. X  l = m_level[MAX_MONS_LEVEL];
  1471. X  do
  1472. X    {
  1473. X      m = randint(l) - 1;
  1474. X      ctr = 0;
  1475. X      do
  1476. X    {
  1477. X      if (c_list[m].cdefense & CD_UNDEAD)
  1478. X        {
  1479. X          ctr = 20;
  1480. X          l     = 0;
  1481. X        }
  1482. X      else
  1483. X        {
  1484. X          m++;
  1485. X          if (m > l)
  1486. X        ctr = 20;
  1487. X          else
  1488. X        ctr++;
  1489. X        }
  1490. X    }
  1491. X      while (ctr <= 19);
  1492. X    }
  1493. X  while(l != 0);
  1494. X  do
  1495. X    {
  1496. X      j = *y - 2 + randint(3);
  1497. X      k = *x - 2 + randint(3);
  1498. X      if (in_bounds(j, k))
  1499. X    {
  1500. X      cave_ptr = &cave[j][k];
  1501. X      if (cave_ptr->fval <= MAX_OPEN_SPACE && (cave_ptr->cptr == 0))
  1502. X        {
  1503. X          /* Place_monster() should always return TRUE here.  */
  1504. X          if (! place_monster(j, k, m, FALSE))
  1505. X        return FALSE;
  1506. X          summon = TRUE;
  1507. X          i = 9;
  1508. X          *y = j;
  1509. X          *x = k;
  1510. X        }
  1511. X    }
  1512. X      i++;
  1513. X    }
  1514. X  while(i <= 9);
  1515. X  return(summon);
  1516. X}
  1517. X
  1518. X
  1519. X/* If too many objects on floor level, delete some of them-RAK-    */
  1520. Xstatic void compact_objects()
  1521. X{
  1522. X  register int i, j;
  1523. X  int ctr, cur_dis, chance;
  1524. X  register cave_type *cave_ptr;
  1525. X
  1526. X  msg_print("Compacting objects...");
  1527. X
  1528. X  ctr = 0;
  1529. X  cur_dis = 66;
  1530. X  do
  1531. X    {
  1532. X      for (i = 0; i < cur_height; i++)
  1533. X    for (j = 0; j < cur_width; j++)
  1534. X      {
  1535. X        cave_ptr = &cave[i][j];
  1536. X        if ((cave_ptr->tptr != 0)
  1537. X        && (distance(i, j, char_row, char_col) > cur_dis))
  1538. X          {
  1539. X        switch(t_list[cave_ptr->tptr].tval)
  1540. X          {
  1541. X          case TV_VIS_TRAP:
  1542. X            chance = 15;
  1543. X            break;
  1544. X          case TV_INVIS_TRAP:
  1545. X          case TV_RUBBLE:
  1546. X          case TV_OPEN_DOOR: case TV_CLOSED_DOOR:
  1547. X            chance = 5;
  1548. X            break;
  1549. X          case TV_UP_STAIR: case TV_DOWN_STAIR:
  1550. X          case TV_STORE_DOOR:
  1551. X            /* stairs, don't delete them */
  1552. X            /* shop doors, don't delete them */
  1553. X            chance = 0;
  1554. X            break;
  1555. X          case TV_SECRET_DOOR: /* secret doors */
  1556. X            chance = 3;
  1557. X            break;
  1558. X          default:
  1559. X            chance = 10;
  1560. X          }
  1561. X        if (randint (100) <= chance)
  1562. X          {
  1563. X            (void) delete_object(i, j);
  1564. X            ctr++;
  1565. X          }
  1566. X          }
  1567. X      }
  1568. X      if (ctr == 0)  cur_dis -= 6;
  1569. X    }
  1570. X  while (ctr <= 0);
  1571. X  if (cur_dis < 66)  prt_map();
  1572. X}
  1573. X
  1574. X/* Gives pointer to next free space            -RAK-    */
  1575. Xint popt()
  1576. X{
  1577. X  if (tcptr == MAX_TALLOC)
  1578. X    compact_objects();
  1579. X  return (tcptr++);
  1580. X}
  1581. X
  1582. X
  1583. X/* Pushs a record back onto free space list        -RAK-    */
  1584. X/* Delete_object() should always be called instead, unless the object in
  1585. X   question is not in the dungeon, e.g. in store1.c and files.c */
  1586. Xvoid pusht(x)
  1587. Xregister int8u x;
  1588. X{
  1589. X  register int i, j;
  1590. X
  1591. X  if (x != tcptr - 1)
  1592. X    {
  1593. X      t_list[x] = t_list[tcptr - 1];
  1594. X
  1595. X      /* must change the tptr in the cave of the object just moved */
  1596. X      for (i = 0; i < cur_height; i++)
  1597. X    for (j = 0; j < cur_width; j++)
  1598. X      if (cave[i][j].tptr == tcptr - 1)
  1599. X        cave[i][j].tptr = x;
  1600. X    }
  1601. X  tcptr--;
  1602. X  invcopy(&t_list[tcptr], OBJ_NOTHING);
  1603. X}
  1604. X
  1605. X
  1606. X/* Boolean : is object enchanted      -RAK- */
  1607. Xint magik(chance)
  1608. Xint chance;
  1609. X{
  1610. X  if (randint(100) <= chance)
  1611. X    return(TRUE);
  1612. X  else
  1613. X    return(FALSE);
  1614. X}
  1615. X
  1616. X
  1617. X/* Enchant a bonus based on degree desired -RAK- */
  1618. Xint m_bonus(base, max_std, level)
  1619. Xint base, max_std, level;
  1620. X{
  1621. X  register int x, stand_dev, tmp;
  1622. X
  1623. X  stand_dev = (OBJ_STD_ADJ * level / 100) + OBJ_STD_MIN;
  1624. X  /* Check for level > max_std since that may have generated an overflow.  */
  1625. X  if (stand_dev > max_std || level > max_std)
  1626. X    stand_dev = max_std;
  1627. X  /* abs may be a macro, don't call it with randnor as a parameter */
  1628. X  tmp = randnor(0, stand_dev);
  1629. X  x = (abs(tmp) / 10) + base;
  1630. X  if (x < base)
  1631. X    return(base);
  1632. X  else
  1633. X    return(x);
  1634. X}
  1635. END_OF_FILE
  1636. if test 24413 -ne `wc -c <'source/misc1.c'`; then
  1637.     echo shar: \"'source/misc1.c'\" unpacked with wrong size!
  1638. fi
  1639. # end of 'source/misc1.c'
  1640. fi
  1641. if test -f 'vms/moria.opt' -a "${1}" != "-c" ; then 
  1642.   echo shar: Will not clobber existing file \"'vms/moria.opt'\"
  1643. else
  1644. echo shar: Extracting \"'vms/moria.opt'\" \(754 characters\)
  1645. sed "s/^X//" >'vms/moria.opt' <<'END_OF_FILE'
  1646. XMAIN.OBJ, -
  1647. XCREATE.OBJ, -
  1648. XCREATURE.OBJ, -
  1649. XDEATH.OBJ, -
  1650. XDESC.OBJ, -
  1651. XDUNGEON.OBJ, -
  1652. XEAT.OBJ, -
  1653. XFILES.OBJ, -
  1654. XGENERATE.OBJ, -
  1655. XGETCH.OBJ, -
  1656. XHELP.OBJ, -
  1657. XIO.OBJ, -
  1658. XMAGIC.OBJ, -
  1659. XMISC1.OBJ, -
  1660. XMISC2.OBJ, -
  1661. XMISC3.OBJ, -
  1662. XMISC4.OBJ, -
  1663. XMONSTERS.OBJ, -
  1664. XMORIA1.OBJ, -
  1665. XMORIA2.OBJ, -
  1666. XMORIA3.OBJ, -
  1667. XMORIA4.OBJ, -
  1668. XPLAYER.OBJ, -
  1669. XPOTIONS.OBJ, -
  1670. XPRAYER.OBJ, -
  1671. XRECALL.OBJ, -
  1672. XRND.OBJ, -
  1673. XSAVE.OBJ, -
  1674. XSCROLLS.OBJ, -
  1675. XSETS.OBJ, -
  1676. XSIGNALS.OBJ, -
  1677. XSPELLS.OBJ, -
  1678. XSTAFFS.OBJ, -
  1679. XSTORE1.OBJ, -
  1680. XSTORE2.OBJ, -
  1681. XTABLES.OBJ, -
  1682. XTREASURE.OBJ, -
  1683. XUEXIT.OBJ, -
  1684. XVARIABLE.OBJ, -
  1685. XWANDS.OBJ, -
  1686. XWIZARD.OBJ, -
  1687. XSYS$LIBRARY:VAXCRTl/share
  1688. X! ^ char input
  1689. X!         ^ small stubs for cbreak(), nocbreak()
  1690. X!                  ^ small stub for exit() call
  1691. X!                           ^ links us with the RTLibrary
  1692. END_OF_FILE
  1693. if test 754 -ne `wc -c <'vms/moria.opt'`; then
  1694.     echo shar: \"'vms/moria.opt'\" unpacked with wrong size!
  1695. fi
  1696. # end of 'vms/moria.opt'
  1697. fi
  1698. echo shar: End of archive 26 \(of 39\).
  1699. cp /dev/null ark26isdone
  1700. MISSING=""
  1701. 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
  1702.     if test ! -f ark${I}isdone ; then
  1703.     MISSING="${MISSING} ${I}"
  1704.     fi
  1705. done
  1706. if test "${MISSING}" = "" ; then
  1707.     echo You have unpacked all 39 archives.
  1708.     echo "Now run "bldfiles.sh" to build split files"
  1709.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1710. else
  1711.     echo You still need to unpack the following archives:
  1712.     echo "        " ${MISSING}
  1713. fi
  1714. ##  End of shell archive.
  1715. exit 0
  1716.