games@tekred.TEK.COM (07/27/88)
Submitted by: "James E. Wilson" <wilson@ji.berkeley.edu>
Comp.sources.games: Volume 5, Issue 37
Archive-name: umoria2/Part06
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 6 (of 18)."
# Contents: misc2.c types.h
# Wrapped by billr@saab on Wed Jul 13 11:16:23 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'misc2.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'misc2.c'\"
else
echo shar: Extracting \"'misc2.c'\" \(42026 characters\)
sed "s/^X//" >'misc2.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <sys/types.h>
X
X#include "constants.h"
X#include "config.h"
X#include "types.h"
X#include "externs.h"
X
X#ifdef USG
X#include <string.h>
X#else
X#include <strings.h>
X#endif
X
X#ifdef sun /* correct SUN stupidity in the stdio.h file */
Xchar *sprintf();
X#endif
X
X#if defined(ultrix) || defined(sun) || defined(USG)
Xint getuid();
X#else
Xuid_t getuid();
X#endif
X
X/* Places a particular trap at location y, x -RAK- */
Xplace_trap(y, x, typ, subval)
Xint y, x, typ, subval;
X{
X int cur_pos;
X treasure_type cur_trap;
X
X if (typ == 1)
X cur_trap = trap_lista[subval];
X else
X cur_trap = trap_listb[subval];
X popt(&cur_pos);
X cave[y][x].tptr = cur_pos;
X t_list[cur_pos] = cur_trap;
X}
X
X
X/* Places rubble at location y, x -RAK- */
Xplace_rubble(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X cave_ptr->fopen = FALSE;
X t_list[cur_pos] = rubble;
X}
X
X
Xplace_open_door(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = door_list[0];
X cave_ptr->fval = corr_floor3.ftval;
X cave_ptr->fopen = TRUE;
X}
X
X
Xplace_broken_door(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = door_list[0];
X cave_ptr->fval = corr_floor3.ftval;
X cave_ptr->fopen = TRUE;
X t_list[cur_pos].p1 = 1;
X}
X
X
Xplace_closed_door(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = door_list[1];
X cave_ptr->fval = corr_floor3.ftval;
X cave_ptr->fopen = FALSE;
X}
X
X
Xplace_locked_door(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = door_list[1];
X cave_ptr->fval = corr_floor3.ftval;
X cave_ptr->fopen = FALSE;
X t_list[cur_pos].p1 = randint(10) + 10;
X}
X
X
Xplace_stuck_door(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = door_list[1];
X cave_ptr->fval = corr_floor3.ftval;
X cave_ptr->fopen = FALSE;
X t_list[cur_pos].p1 = -randint(10) - 10;
X}
X
X
Xplace_secret_door(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X popt(&cur_pos);
X cave_ptr = &cave[y][x];
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = door_list[2];
X cave_ptr->fval = corr_floor4.ftval;
X cave_ptr->fopen = FALSE;
X}
X
X
Xplace_door(y, x)
Xint y, x;
X{
X switch(randint(3))
X {
X case 1:
X switch(randint(4))
X {
X case 1:
X place_broken_door(y, x);
X break;
X default:
X place_open_door(y, x);
X break;
X }
X break;
X case 2:
X switch(randint(12))
X {
X case 1: case 2:
X place_locked_door(y, x);
X break;
X case 3:
X place_stuck_door(y, x);
X break;
X default:
X place_closed_door(y, x);
X break;
X }
X case 3:
X place_secret_door(y, x);
X break;
X }
X}
X
X
X/* Place an up staircase at given y, x -RAK- */
Xplace_up_stairs(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X cave_ptr = &cave[y][x];
X if (cave_ptr->tptr != 0)
X {
X pusht((int)cave_ptr->tptr);
X cave_ptr->tptr = 0;
X cave_ptr->fopen = TRUE;
X }
X popt(&cur_pos);
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = up_stair;
X}
X
X
X/* Place a down staircase at given y, x -RAK- */
Xplace_down_stairs(y, x)
Xint y, x;
X{
X int cur_pos;
X register cave_type *cave_ptr;
X
X cave_ptr = &cave[y][x];
X if (cave_ptr->tptr != 0)
X {
X pusht((int)cave_ptr->tptr);
X cave_ptr->tptr = 0;
X cave_ptr->fopen = TRUE;
X }
X popt(&cur_pos);
X cave_ptr->tptr = cur_pos;
X t_list[cur_pos] = down_stair;
X}
X
X/* Places a staircase 1==up, 2==down -RAK- */
Xplace_stairs(typ, num, walls)
Xint typ, num, walls;
X{
X register cave_type *cave_ptr;
X int i, j;
X register int y1, x1, y2, x2;
X int flag;
X
X for (i = 0; i < num; i++)
X {
X flag = FALSE;
X do
X {
X j = 0;
X do
X {
X y1 = randint(cur_height - 12) - 1;
X x1 = randint(cur_width - 12) - 1;
X y2 = y1 + 12;
X x2 = x1 + 12;
X do
X {
X do
X {
X cave_ptr = &cave[y1][x1];
X if ((cave_ptr->fval == 1) || (cave_ptr->fval == 2) ||
X (cave_ptr->fval == 4))
X if (cave_ptr->tptr == 0)
X if (next_to4(y1, x1, 10, 11, 12) >= walls)
X {
X flag = TRUE;
X switch(typ)
X {
X case 1:
X place_up_stairs(y1, x1);
X break;
X case 2:
X place_down_stairs(y1, x1);
X break;
X }
X }
X x1++;
X }
X while ((x1 != x2) && (!flag));
X x1 = x2 - 12;
X y1++;
X }
X while ((y1 != y2) && (!flag));
X j++;
X }
X while ((!flag) && (j <= 30));
X walls--;
X }
X while (!flag);
X }
X}
X
X
X/* Places a treasure (Gold or Gems) at given row, column -RAK- */
Xplace_gold(y, x)
Xint y, x;
X{
X int cur_pos;
X register int i;
X register treasure_type *t_ptr;
X
X popt(&cur_pos);
X i = ((randint(dun_level+2)+2)/2.0) - 1;
X if (randint(OBJ_GREAT) == 1)
X i += randint(dun_level+1);
X if (i >= MAX_GOLD)
X i = MAX_GOLD - 1;
X cave[y][x].tptr = cur_pos;
X t_list[cur_pos] = gold_list[i];
X t_ptr = &t_list[cur_pos];
X t_ptr->cost += randint(8*t_ptr->cost);
X}
X
X
X/* Returns the array number of a random object -RAK- */
Xint get_obj_num(level)
Xint level;
X{
X register int i;
X
X if (level > MAX_OBJ_LEVEL)
X level = MAX_OBJ_LEVEL;
X if (randint(OBJ_GREAT) == 1)
X level = MAX_OBJ_LEVEL;
X if (level == 0)
X i = randint(t_level[0]) - 1;
X else
X i = randint(t_level[level]) - 1;
X return(i);
X}
X
X
X/* Places an object at given row, column co-ordinate -RAK- */
Xplace_object(y, x)
Xint y, x;
X{
X int cur_pos;
X int tmp;
X treasure_type tr_tmp;;
X
X popt(&cur_pos);
X cave[y][x].tptr = cur_pos;
X /* split this line up to avoid a reported compiler bug */
X tmp = get_obj_num(dun_level);
X tr_tmp = object_list[tmp];
X t_list[cur_pos] = tr_tmp;
X magic_treasure(cur_pos, dun_level);
X}
X
X
X/* Allocates an object for tunnels and rooms -RAK- */
Xalloc_object(alloc_set, typ, num)
Xint (*alloc_set)();
Xint typ, num;
X{
X register int i, j, k;
X
X for (k = 0; k < num; k++)
X {
X do
X {
X i = randint(cur_height) - 1;
X j = randint(cur_width) - 1;
X }
X while ((!(*alloc_set)(cave[i][j].fval)) ||
X (cave[i][j].tptr != 0));
X switch(typ)
X {
X case 1:
X place_trap(i, j, 1, randint(MAX_TRAPA)-1);
X break;
X case 2:
X place_trap(i, j, 2, randint(MAX_TRAPB)-1);
X break;
X case 3:
X place_rubble(i, j);
X break;
X case 4:
X place_gold(i, j);
X break;
X case 5:
X place_object(i, j);
X break;
X }
X }
X}
X
X
X/* Creates objects nearby the coordinates given -RAK- */
Xrandom_object(y, x, num)
Xint y, x, num;
X{
X register int i, j, k;
X register cave_type *cave_ptr;
X
X do
X {
X i = 0;
X do
X {
X j = y - 3 + randint(5);
X k = x - 4 + randint(7);
X cave_ptr = &cave[j][k];
X if ((cave_ptr->fval <= 7) && (cave_ptr->fval >= 1))
X if (cave_ptr->tptr == 0)
X {
X if (randint(100) < 75)
X place_object(j, k);
X else
X place_gold(j, k);
X i = 9;
X }
X i++;
X }
X while(i <= 10);
X num--;
X }
X while (num != 0);
X}
X
X
X/* Converts stat num into string -RAK- */
Xcnv_stat(stat, out_val)
Xbyteint stat;
Xchar *out_val;
X{
X vtype tmp_str;
X register int part1, part2;
X
X if (stat > 18)
X {
X part1 = 18;
X part2 = stat - 18;
X if (part2 == 100)
X (void) strcpy(tmp_str, "18/100");
X else if (part2 < 10)
X (void) sprintf(tmp_str, " %2d/0%d", part1, part2);
X else
X (void) sprintf(tmp_str, " %2d/%2d", part1, part2);
X }
X else
X (void) sprintf(tmp_str, "%6d", stat);
X if (strlen(tmp_str) < 6)
X (void) strcpy(tmp_str, pad(tmp_str, " ", 6));
X (void) strcpy(out_val, tmp_str);
X}
X
X
X/* Print character stat in given row, column -RAK- */
Xprt_stat(stat_name, stat, row, column)
Xvtype stat_name;
Xbyteint stat;
Xint row, column;
X{
X stat_type out_val1;
X vtype out_val2;
X
X cnv_stat(stat, out_val1);
X (void) strcpy(out_val2, stat_name);
X (void) strcat(out_val2, out_val1);
X put_buffer(out_val2, row, column);
X}
X
X
X/* Print character info in given row, column -RAK- */
X/* the longest title is 13 characters, so only pad to 13 */
Xprt_field(info, row, column)
Xvtype info;
Xint row, column;
X{
X put_buffer(pad(info, " ", 13), row, column);
X}
X
X
X/* Print number with header at given row, column -RAK- */
Xprt_num(header, num, row, column)
Xvtype header;
Xint num, row, column;
X{
X vtype out_val;
X
X (void) sprintf(out_val, "%s%6d", header, num);
X put_buffer(out_val, row, column);
X}
X
X
X/* Adjustment for wisdom -JWT- */
Xint wis_adj()
X{
X if (py.stats.cwis > 117)
X return(7);
X else if (py.stats.cwis > 107)
X return(6);
X else if (py.stats.cwis > 87)
X return(5);
X else if (py.stats.cwis > 67)
X return(4);
X else if (py.stats.cwis > 17)
X return(3);
X else if (py.stats.cwis > 14)
X return(2);
X else if (py.stats.cwis > 7)
X return(1);
X else
X return(0);
X}
X
X/* adjustment for intelligence -JWT- */
Xint int_adj()
X{
X if (py.stats.cint > 117)
X return(7);
X else if (py.stats.cint > 107)
X return(6);
X else if (py.stats.cint > 87)
X return(5);
X else if (py.stats.cint > 67)
X return(4);
X else if (py.stats.cint > 17)
X return(3);
X else if (py.stats.cint > 14)
X return(2);
X else if (py.stats.cint > 7)
X return(1);
X else
X return(0);
X}
X
X
X/* Adjustment for charisma -RAK- */
X/* Percent decrease or increase in price of goods */
Xdouble chr_adj()
X{
X if (py.stats.cchr > 117)
X return(-0.10);
X else if (py.stats.cchr > 107)
X return(-0.08);
X else if (py.stats.cchr > 87)
X return(-0.06);
X else if (py.stats.cchr > 67)
X return(-0.04);
X else if (py.stats.cchr > 18)
X return(-0.02);
X else
X switch(py.stats.cchr)
X {
X case 18: return(0.00);
X case 17: return(0.01);
X case 16: return(0.02);
X case 15: return(0.03);
X case 14: return(0.04);
X case 13: return(0.06);
X case 12: return(0.08);
X case 11: return(0.10);
X case 10: return(0.12);
X case 9: return(0.14);
X case 8: return(0.16);
X case 7: return(0.18);
X case 6: return(0.20);
X case 5: return(0.22);
X case 4: return(0.24);
X case 3: return(0.25);
X default: return(0.00); /* Error trap */
X }
X}
X
X
X/* Returns a character's adjustment to hit points -JWT- */
Xint con_adj()
X{
X if (py.stats.ccon == 3)
X return(-4);
X else if (py.stats.ccon == 4)
X return(-3);
X else if (py.stats.ccon == 5)
X return(-2);
X else if (py.stats.ccon == 6)
X return(-1);
X else if (py.stats.ccon < 17)
X return(0);
X else if (py.stats.ccon == 17)
X return(1);
X else if (py.stats.ccon < 94)
X return(2);
X else if (py.stats.ccon < 117)
X return(3);
X else
X return(4);
X}
X
X
X/* Calculates hit points for each level that is gained. -RAK- */
Xint get_hitdie()
X{
X register int hitpoints;
X
X hitpoints = randint((int)py.misc.hitdie) + con_adj();
X /* always give 'em at least one point */
X if (hitpoints < 1)
X hitpoints = 1;
X return(hitpoints);
X}
X
X
X/* Prints title of character -RAK- */
Xprt_title()
X{
X prt_field(py.misc.title, 4, stat_column);
X}
X
X
X/* Prints strength -RAK- */
Xprt_strength()
X{
X prt_stat("\0", py.stats.cstr, 6, stat_column+6);
X}
X
X
X/* Prints intelligence -RAK- */
Xprt_intelligence()
X{
X prt_stat("\0", py.stats.cint, 7, stat_column+6);
X}
X
X
X/* Prints wisdom -RAK- */
Xprt_wisdom()
X{
X prt_stat("\0", py.stats.cwis, 8, stat_column+6);
X}
X
X
X/* Prints dexterity -RAK- */
Xprt_dexterity()
X{
X prt_stat("\0", py.stats.cdex, 9, stat_column+6);
X}
X
X
X/* Prints constitution -RAK- */
Xprt_constitution()
X{
X prt_stat("\0", py.stats.ccon, 10, stat_column+6);
X}
X
X
X/* Prints charisma -RAK- */
Xprt_charisma()
X{
X prt_stat("\0", py.stats.cchr, 11, stat_column+6);
X}
X
X
X/* Prints level -RAK- */
Xprt_level()
X{
X prt_num("\0", (int)py.misc.lev, 13, stat_column+6);
X}
X
X
X/* Prints players current mana points (a real number...) -RAK- */
Xprt_cmana()
X{
X prt_num("\0", (int)(py.misc.cmana), 15, stat_column+6);
X}
X
X
X/* Prints Max hit points -RAK- */
Xprt_mhp()
X{
X prt_num("\0", py.misc.mhp, 16, stat_column+6);
X}
X
X
X/* Prints players current hit points (a real number...) -RAK- */
Xprt_chp()
X{
X prt_num("\0", (int)(py.misc.chp), 17, stat_column+6);
X}
X
X
X/* prints current AC -RAK- */
Xprt_pac()
X{
X prt_num("\0", py.misc.dis_ac, 19, stat_column+6);
X}
X
X
X/* Prints current gold -RAK- */
Xprt_gold()
X{
X prt_num("\0", py.misc.au, 20, stat_column+6);
X}
X
X
X/* Prints depth in stat area -RAK- */
Xprt_depth()
X{
X vtype depths;
X register int depth;
X
X depth = dun_level*50;
X if (depth == 0)
X (void) strcpy(depths, "Town level");
X else
X (void) sprintf(depths, "Depth: %d (feet)", depth);
X prt(depths, 23, 60);
X}
X
X
X/* Prints status of hunger -RAK- */
Xprt_hunger()
X{
X if (0x000002 & py.flags.status)
X put_buffer("Weak ", 23, 0);
X else if (0x000001 & py.flags.status)
X put_buffer("Hungry ", 23, 0);
X else
X put_buffer(" ", 23, 0);
X}
X
X
X/* Prints Blind status -RAK- */
Xprt_blind()
X{
X if (0x000004 & py.flags.status)
X put_buffer("Blind ", 23, 8);
X else
X put_buffer(" ", 23, 8);
X}
X
X
X/* Prints Confusion status -RAK- */
Xprt_confused()
X{
X if (0x000008 & py.flags.status)
X put_buffer("Confused ", 23, 15);
X else
X put_buffer(" ", 23, 15);
X}
X
X
X/* Prints Fear status -RAK- */
Xprt_afraid()
X{
X if (0x000010 & py.flags.status)
X put_buffer("Afraid ", 23, 25);
X else
X put_buffer(" ", 23, 25);
X}
X
X
X/* Prints Poisoned status -RAK- */
Xprt_poisoned()
X{
X if (0x000020 & py.flags.status)
X put_buffer("Poisoned ", 23, 33);
X else
X put_buffer(" ", 23, 33);
X}
X
X
X/* Prints Searching status -RAK- */
Xprt_search()
X{
X if (0x000100 & py.flags.status)
X put_buffer("Searching ", 23, 43);
X else
X put_buffer(" ", 23, 43);
X}
X
X
X/* Prints Resting status -RAK- */
Xprt_rest()
X{
X if (0x000200 & py.flags.status)
X put_buffer("Resting ", 23, 43);
X else
X put_buffer(" ", 23, 43);
X}
X
X
X/* Prints winner status on display -RAK- */
Xprt_winner()
X{
X put_buffer("*Winner*", 22, 0);
X}
X
X
X/* Increases a stat by one randomized level -RAK- */
Xbyteint in_statp(stat)
Xregister byteint stat;
X{
X if (stat < 18)
X stat++;
X else if (stat < 88)
X stat += randint(25);
X else if (stat < 108)
X stat += randint(10);
X else
X stat++;
X if (stat > 118)
X stat = 118;
X return(stat);
X}
X
X
X/* Decreases a stat by one randomized level -RAK- */
Xbyteint de_statp(stat)
Xregister byteint stat;
X{
X if (stat < 19)
X stat--;
X else if (stat < 109)
X {
X stat += -randint(10) - 5;
X if (stat < 18)
X stat = 18;
X }
X else
X stat -= randint(3);
X if (stat < 3)
X stat = 3;
X return(stat);
X}
X
X
X/* Increases a stat by one true level -RAK- */
Xbyteint in_statt(stat)
Xregister byteint stat;
X{
X if (stat < 18)
X stat++;
X else
X {
X stat += 10;
X if (stat > 118)
X stat = 118;
X }
X return(stat);
X}
X
X
X/* Decreases a stat by true level -RAK- */
Xbyteint de_statt(stat)
Xregister byteint stat;
X{
X if (stat > 27)
X stat -= 10;
X else if (stat > 18)
X stat = 18;
X else
X {
X stat--;
X if (stat < 3)
X stat = 3;
X }
X return(stat);
X}
X
X
X/* Returns a character's adjustment to hit. -JWT- */
Xint tohit_adj()
X{
X register int total;
X register struct stats *s_ptr;
X
X s_ptr = &py.stats;
X if (s_ptr->cdex < 4) total = -3;
X else if (s_ptr->cdex < 6) total = -2;
X else if (s_ptr->cdex < 8) total = -1;
X else if (s_ptr->cdex < 16) total = 0;
X else if (s_ptr->cdex < 17) total = 1;
X else if (s_ptr->cdex < 18) total = 2;
X else if (s_ptr->cdex < 69) total = 3;
X else if (s_ptr->cdex < 118) total = 4;
X else total = 5;
X if (s_ptr->cstr < 4) total -= 3;
X else if (s_ptr->cstr < 5) total -= 2;
X else if (s_ptr->cstr < 7) total -= 1;
X else if (s_ptr->cstr < 18) total -= 0;
X else if (s_ptr->cstr < 94) total += 1;
X else if (s_ptr->cstr < 109) total += 2;
X else if (s_ptr->cstr < 117) total += 3;
X else total += 4;
X return(total);
X}
X
X
X/* Returns a character's adjustment to armor class -JWT- */
Xint toac_adj()
X{
X register struct stats *s_ptr;
X
X s_ptr = &py.stats;
X if (s_ptr->cdex < 4) return(-4);
X else if (s_ptr->cdex == 4) return(-3);
X else if (s_ptr->cdex == 5) return(-2);
X else if (s_ptr->cdex == 6) return(-1);
X else if (s_ptr->cdex < 15) return( 0);
X else if (s_ptr->cdex < 18) return( 1);
X else if (s_ptr->cdex < 59) return( 2);
X else if (s_ptr->cdex < 94) return( 3);
X else if (s_ptr->cdex < 117) return( 4);
X else return( 5);
X}
X
X
X/* Returns a character's adjustment to disarm -RAK- */
Xint todis_adj()
X{
X register struct stats *s_ptr;
X
X s_ptr = &py.stats;
X if (s_ptr->cdex == 3) return(-8);
X else if (s_ptr->cdex == 4) return(-6);
X else if (s_ptr->cdex == 5) return(-4);
X else if (s_ptr->cdex == 6) return(-2);
X else if (s_ptr->cdex == 7) return(-1);
X else if (s_ptr->cdex < 13) return( 0);
X else if (s_ptr->cdex < 16) return( 1);
X else if (s_ptr->cdex < 18) return( 2);
X else if (s_ptr->cdex < 59) return( 4);
X else if (s_ptr->cdex < 94) return( 5);
X else if (s_ptr->cdex < 117) return( 6);
X else return( 8);
X}
X
X
X/* Returns a character's adjustment to damage -JWT- */
Xint todam_adj()
X{
X register struct stats *s_ptr;
X
X s_ptr = &py.stats;
X if (s_ptr->cstr < 4) return(-2);
X else if (s_ptr->cstr < 5) return(-1);
X else if (s_ptr->cstr < 16) return( 0);
X else if (s_ptr->cstr < 17) return( 1);
X else if (s_ptr->cstr < 18) return( 2);
X else if (s_ptr->cstr < 94) return( 3);
X else if (s_ptr->cstr < 109) return( 4);
X else if (s_ptr->cstr < 117) return( 5);
X else return( 6);
X}
X
X
X/* Prints character-screen info -RAK- */
Xprt_stat_block()
X{
X register int status;
X register struct stats *s_ptr;
X register struct misc *m_ptr;
X
X s_ptr = &py.stats;
X m_ptr = &py.misc;
X prt_field(m_ptr->race, 2, stat_column);
X prt_field(m_ptr->tclass, 3, stat_column);
X prt_field(m_ptr->title, 4, stat_column);
X prt_stat("STR : ", s_ptr->cstr, 6, stat_column);
X prt_stat("INT : ", s_ptr->cint, 7, stat_column);
X prt_stat("WIS : ", s_ptr->cwis, 8, stat_column);
X prt_stat("DEX : ", s_ptr->cdex, 9, stat_column);
X prt_stat("CON : ", s_ptr->ccon, 10, stat_column);
X prt_stat("CHR : ", s_ptr->cchr, 11, stat_column);
X prt_num( "LEV : ", (int)m_ptr->lev, 13, stat_column);
X prt_num( "EXP : ", m_ptr->exp, 14, stat_column);
X prt_num( "MANA: ", (int)(m_ptr->cmana), 15, stat_column);
X prt_num( "MHP : ", m_ptr->mhp, 16, stat_column);
X prt_num( "CHP : ", (int)(m_ptr->chp), 17, stat_column);
X prt_num( "AC : ", m_ptr->dis_ac, 19, stat_column);
X prt_num( "GOLD: ", m_ptr->au, 20, stat_column);
X if (total_winner) prt_winner();
X status = py.flags.status;
X if (0x000003 & status)
X prt_hunger();
X if (0x000004 & status)
X prt_blind();
X if (0x000008 & status)
X prt_confused();
X if (0x000010 & status)
X prt_afraid();
X if (0x000020 & status)
X prt_poisoned();
X if (0x000100 & status)
X prt_search();
X if (0x000200 & status)
X prt_rest();
X}
X
X
X/* Draws entire screen -RAK- */
Xdraw_cave()
X{
X clear_screen(0, 0);
X prt_stat_block();
X prt_map();
X prt_depth();
X}
X
X
X/* Prints the following information on the screen. -JWT- */
Xput_character()
X{
X char tmp_str[80];
X register struct misc *m_ptr;
X
X m_ptr = &py.misc;
X clear_screen(0, 0);
X prt(strcat(strcpy(tmp_str, "Name : "), m_ptr->name), 2, 2);
X prt(strcat(strcpy(tmp_str, "Race : "), m_ptr->race), 3, 2);
X prt(strcat(strcpy(tmp_str, "Sex : "), m_ptr->sex), 4, 2);
X prt(strcat(strcpy(tmp_str, "Class : "), m_ptr->tclass), 5, 2);
X}
X
X
X/* Prints the following information on the screen. -JWT- */
Xput_stats()
X{
X register struct stats *s_ptr;
X register struct misc *m_ptr;
X
X m_ptr = &py.misc;
X s_ptr = &py.stats;
X prt_stat("STR : ", s_ptr->cstr, 2, 64);
X prt_stat("INT : ", s_ptr->cint, 3, 64);
X prt_stat("WIS : ", s_ptr->cwis, 4, 64);
X prt_stat("DEX : ", s_ptr->cdex, 5, 64);
X prt_stat("CON : ", s_ptr->ccon, 6, 64);
X prt_stat("CHR : ", s_ptr->cchr, 7, 64);
X prt_num("+ To Hit : ", m_ptr->dis_th, 9, 3);
X prt_num("+ To Damage: ", m_ptr->dis_td, 10, 3);
X prt_num("+ To AC : ", m_ptr->dis_tac, 11, 3);
X prt_num(" Total AC : ", m_ptr->dis_ac, 12, 3);
X}
X
X
X/* Returns a rating of x depending on y -JWT- */
Xchar *likert(x, y)
Xint x, y;
X{
X switch((x/y))
X {
X case -3: case -2: case -1: return("Very Bad");
X case 0: case 1: return("Bad");
X case 2: return("Poor");
X case 3: case 4: return("Fair");
X case 5: return("Good");
X case 6: return("Very Good");
X case 7: case 8: return("Excellent");
X default: return("Superb");
X }
X}
X
X
X/* Prints age, height, weight, and SC -JWT- */
Xput_misc1()
X{
X register struct misc *m_ptr;
X
X m_ptr = &py.misc;
X prt_num("Age : ", (int)m_ptr->age, 2, 39);
X prt_num("Height : ", (int)m_ptr->ht, 3, 39);
X prt_num("Weight : ", (int)m_ptr->wt, 4, 39);
X prt_num("Social Class : ", (int)m_ptr->sc, 5, 39);
X}
X
X
X/* Prints the following information on the screen. -JWT- */
Xput_misc2()
X{
X register struct misc *m_ptr;
X
X m_ptr = &py.misc;
X prt_num("Level : ", (int)m_ptr->lev, 9, 30);
X prt_num("Experience : ", m_ptr->exp, 10, 30);
X prt_num("Gold : ", m_ptr->au, 11, 30);
X prt_num("Max Hit Points : ", m_ptr->mhp, 9, 53);
X prt_num("Cur Hit Points : ", (int)m_ptr->chp, 10, 53);
X prt_num("Max Mana : ", m_ptr->mana, 11, 53);
X prt_num("Cur Mana : ", (int)m_ptr->cmana, 12, 53);
X}
X
X
X/* Prints ratings on certain abilities -RAK- */
Xput_misc3()
X{
X int xbth, xbthb, xfos, xsrh, xstl, xdis, xsave, xdev;
X vtype xinfra;
X register struct misc *p_ptr;
X char tmp_str[80];
X
X clear_screen(13, 0);
X p_ptr = &py.misc;
X xbth = p_ptr->bth + p_ptr->lev*BTH_LEV_ADJ + p_ptr->ptohit*BTH_PLUS_ADJ;
X xbthb = p_ptr->bthb + p_ptr->lev*BTH_LEV_ADJ + p_ptr->ptohit*BTH_PLUS_ADJ;
X /* this results in a range from 0 to 29 */
X xfos = 40 - p_ptr->fos;
X if (xfos < 0) xfos = 0;
X xsrh = p_ptr->srh + int_adj();
X /* this results in a range from 0 to 9 */
X xstl = p_ptr->stl + 1;
X xdis = p_ptr->disarm + p_ptr->lev + 2*todis_adj() + int_adj();
X xsave = p_ptr->save + p_ptr->lev + wis_adj();
X xdev = p_ptr->save + p_ptr->lev + int_adj();
X (void) sprintf(xinfra, "%d feet", py.flags.see_infra*10);
X
X prt("(Miscellaneous Abilities)", 15, 23);
X put_buffer(strcat(strcpy(tmp_str, "Fighting : "),
X likert(xbth, 12)), 16, 1);
X put_buffer(strcat(strcpy(tmp_str, "Bows/Throw : "),
X likert(xbthb, 12)), 17, 1);
X put_buffer(strcat(strcpy(tmp_str, "Saving Throw: "),
X likert(xsave, 6)), 18, 1);
X put_buffer(strcat(strcpy(tmp_str, "Stealth : "),
X likert(xstl, 1)), 16, 26);
X put_buffer(strcat(strcpy(tmp_str, "Disarming : "),
X likert(xdis, 8)), 17, 26);
X put_buffer(strcat(strcpy(tmp_str, "Magic Device: "),
X likert(xdev, 6)), 18, 26);
X put_buffer(strcat(strcpy(tmp_str, "Perception : "),
X likert(xfos, 3)), 16, 51);
X put_buffer(strcat(strcpy(tmp_str, "Searching : "),
X likert(xsrh, 6)), 17, 51);
X put_buffer(strcat(strcpy(tmp_str, "Infra-Vision: "), xinfra), 18, 51);
X}
X
X
X/* Used to display the character on the screen. -RAK- */
Xdisplay_char()
X{
X put_character();
X put_misc1();
X put_stats();
X put_misc2();
X put_misc3();
X}
X
X
X/* Gets a name for the character -JWT- */
Xget_name()
X{
X prt("Enter your player's name [press <RETURN> when finished]", 21, 2);
X (void) get_string(py.misc.name, 2, 14, 24);
X clear_screen(20, 0);
X}
X
X
X/* Chances the name of the character -JWT- */
Xchange_name()
X{
X char c;
X int flag;
X
X flag = FALSE;
X display_char();
X do
X {
X prt("<c>hange character name. <ESCAPE> to continue.", 21, 2);
X inkey(&c);
X switch(c)
X {
X case 99:
X get_name();
X break;
X case 0: case 27:
X flag = TRUE;
X break;
X default:
X break;
X }
X }
X while (!flag);
X}
X
X
X/* Builds passwords -RAK- */
Xbpswd()
X{
X (void) strcpy(password1, PASSWD1);
X (void) strcpy(password2, PASSWD2);
X}
X
X
X/* Destroy an item in the inventory -RAK- */
Xinven_destroy(item_val)
Xint item_val;
X{
X register int j;
X register treasure_type *i_ptr;
X
X inventory[INVEN_MAX] = inventory[item_val];
X i_ptr = &inventory[item_val];
X if ((i_ptr->number > 1) && (i_ptr->subval < 512))
X {
X i_ptr->number--;
X inven_weight -= i_ptr->weight;
X inventory[INVEN_MAX].number = 1;
X }
X else
X {
X inven_weight -= i_ptr->weight*i_ptr->number;
X for (j = item_val; j < inven_ctr-1; j++)
X inventory[j] = inventory[j+1];
X inventory[inven_ctr-1] = blank_treasure;
X inven_ctr--;
X }
X}
X
X
X/* Drops an item from inventory to given location -RAK- */
Xinven_drop(item_val, y, x)
Xint item_val, y, x;
X{
X int i;
X register cave_type *cave_ptr;
X
X cave_ptr = &cave[y][x];
X if (cave_ptr->tptr != 0)
X pusht((int)cave_ptr->tptr);
X inven_destroy(item_val);
X popt(&i);
X t_list[i] = inventory[INVEN_MAX];
X cave_ptr->tptr = i;
X}
X
X
X/* Destroys a type of item on a given percent chance -RAK- */
Xint inven_damage(typ, perc)
Xint (*typ)();
Xregister int perc;
X{
X register int i, j;
X
X j = 0;
X for (i = 0; i < inven_ctr; i++)
X if ((*typ)(inventory[i].tval))
X if (randint(100) < perc)
X {
X inven_destroy(i);
X j++;
X }
X return(j);
X}
X
X
X/* Computes current weight limit -RAK- */
Xint weight_limit()
X{
X register int weight_cap;
X
X weight_cap = py.stats.cstr * PLAYER_WEIGHT_CAP + py.misc.wt;
X if (weight_cap > 3000) weight_cap = 3000;
X return(weight_cap);
X}
X
X
X/* Check inventory for too much weight -RAK- */
Xint inven_check_weight()
X{
X register int item_wgt, max_weight;
X register int check_weight;
X
X check_weight = FALSE;
X max_weight = weight_limit();
X item_wgt = inventory[INVEN_MAX].number*inventory[INVEN_MAX].weight;
X /* Now, check to see if player can carry object */
X if ((inven_weight + item_wgt) <= max_weight)
X check_weight = TRUE; /* Can carry weight */
X return(check_weight);
X}
X
X
X/* Check to see if he will be carrying too many objects -RAK- */
Xint inven_check_num()
X{
X register int i;
X register int check_num;
X
X check_num = FALSE;
X if (inven_ctr < 22)
X check_num = TRUE;
X else if (inventory[INVEN_MAX].subval > 255)
X for (i = 0; i < inven_ctr; i++)
X if (inventory[i].tval == inventory[INVEN_MAX].tval)
X if (inventory[i].subval == inventory[INVEN_MAX].subval)
X check_num = TRUE;
X return(check_num);
X}
X
X
X/* Insert INVEN_MAX at given location */
Xinsert_inv(pos, wgt)
Xint pos, wgt;
X{
X register int i;
X
X for (i = inven_ctr-1; i >= pos; i--)
X inventory[i+1] = inventory[i];
X inventory[pos] = inventory[INVEN_MAX];
X inven_ctr++;
X inven_weight += wgt;
X}
X
X
X/* Add the item in INVEN_MAX to players inventory. Return the */
X/* item position for a description if needed... -RAK- */
Xinven_carry(item_val)
Xint *item_val;
X{
X int item_num, wgt;
X register int typ, subt;
X int flag;
X register treasure_type *i_ptr;
X
X /* Now, check to see if player can carry object */
X *item_val = 0;
X flag = FALSE;
X i_ptr = &inventory[INVEN_MAX];
X item_num = i_ptr->number;
X typ = i_ptr->tval;
X subt = i_ptr->subval;
X wgt = i_ptr->number*i_ptr->weight;
X
X do
X {
X i_ptr = &inventory[*item_val];
X if (typ == i_ptr->tval)
X {
X if (subt == i_ptr->subval) /* Adds to other item */
X if (subt > 255)
X {
X i_ptr->number += item_num;
X inven_weight += wgt;
X flag = TRUE;
X }
X }
X else if (typ > i_ptr->tval)
X { /* Insert into list */
X insert_inv(*item_val, wgt);
X flag = TRUE;
X }
X (*item_val)++;
X }
X while ((*item_val < inven_ctr) && (!flag));
X if (!flag) /* Becomes last item in list */
X {
X insert_inv(inven_ctr, wgt);
X *item_val = inven_ctr - 1;
X }
X else
X (*item_val)--;
X}
X
X
X/* Returns spell chance of failure for spell -RAK- */
Xspell_chance(spell)
Xregister spl_rec *spell;
X{
X register spell_type *s_ptr;
X
X s_ptr = &magic_spell[py.misc.pclass][spell->splnum];
X spell->splchn = s_ptr->sfail - 3*(py.misc.lev-s_ptr->slevel);
X if (class[py.misc.pclass].mspell)
X spell->splchn -= 3*(int_adj()-1);
X else
X spell->splchn -= 3*(wis_adj()-1);
X if (s_ptr->smana > py.misc.cmana)
X spell->splchn += 5*(s_ptr->smana-(int)py.misc.cmana);
X if (spell->splchn > 95)
X spell->splchn = 95;
X else if (spell->splchn < 5)
X spell->splchn = 5;
X}
X
X
X/* Print list of spells -RAK- */
Xprint_new_spells(spell, num, redraw)
Xspl_type spell;
Xregister int num;
Xint *redraw;
X{
X register int i;
X vtype out_val;
X register spell_type *s_ptr;
X
X *redraw = TRUE;
X clear_screen(1, 0);
X prt(" Name Level Mana %Failure", 1, 0);
X for (i = 0; i < num; i++)
X {
X s_ptr = &magic_spell[py.misc.pclass][spell[i].splnum];
X spell_chance(&spell[i]);
X (void) sprintf(out_val, "%c) %s%d %d %d", 97+i,
X pad(s_ptr->sname, " ", 30),
X s_ptr->slevel, s_ptr->smana, spell[i].splchn);
X prt(out_val, 2+i, 0);
X }
X}
X
X
X/* Returns spell pointer -RAK- */
Xint get_spell(spell, num, sn, sc, prompt, redraw)
Xspl_type spell;
Xregister int num;
Xregister int *sn, *sc;
Xvtype prompt;
Xint *redraw;
X{
X int flag;
X char choice;
X vtype out_val1;
X
X *sn = -1;
X flag = TRUE;
X (void) sprintf(out_val1, "(Spells a-%c, *==List, <ESCAPE>=exit) %s",
X num+96, prompt);
X prt(out_val1, 0, 0);
X while (((*sn < 0) || (*sn >= num)) && (flag))
X {
X inkey(&choice);
X *sn = (choice);
X switch(*sn)
X {
X case 0: case 27:
X flag = FALSE;
X reset_flag = TRUE;
X break;
X case 42:
X print_new_spells(spell, num, redraw);
X break;
X default:
X *sn -= 97;
X break;
X }
X }
X erase_line(MSG_LINE, 0);
X msg_flag = FALSE;
X if (flag)
X {
X spell_chance(&spell[*sn]);
X *sc = spell[*sn].splchn;
X *sn = spell[*sn].splnum;
X }
X return(flag);
X}
X
X
X/* Learn some magic spells (Mage) -RAK- */
Xint learn_spell(redraw)
Xint *redraw;
X{
X unsigned int j;
X register int i, k, new_spells;
X int sn, sc;
X unsigned int spell_flag;
X spl_type spell;
X int learn;
X register spell_type *s_ptr;
X
X learn = FALSE;
X switch(int_adj())
X {
X case 0: new_spells = 0; break;
X case 1: new_spells = 1; break;
X case 2: new_spells = 1; break;
X case 3: new_spells = 1; break;
X case 4: new_spells = randint(2); break;
X case 5: new_spells = randint(2); break;
X case 6: new_spells = randint(3); break;
X case 7: new_spells = randint(2)+1; break;
X default: new_spells = 0; break;
X }
X i = 0;
X spell_flag = 0;
X do
X {
X if (inventory[i].tval == 90)
X spell_flag |= inventory[i].flags;
X i++;
X }
X while (i < inven_ctr);
X while ((new_spells > 0) && (spell_flag != 0))
X {
X i = 0;
X j = spell_flag;
X do
X {
X k = bit_pos(&j);
X s_ptr = &magic_spell[py.misc.pclass][k];
X if (s_ptr->slevel <= py.misc.lev)
X if (!s_ptr->learned)
X {
X spell[i].splnum = k;
X i++;
X }
X }
X while(j != 0);
X if (i > 0)
X {
X print_new_spells(spell, i, redraw);
X if (get_spell(spell, i, &sn, &sc, "Learn which spell?", redraw))
X {
X magic_spell[py.misc.pclass][sn].learned = TRUE;
X learn = TRUE;
X new_spells--;
X if (py.misc.mana == 0)
X {
X py.misc.mana = 1;
X py.misc.cmana = 1.0;
X }
X }
X /* else do nothing if get_spell fails */
X }
X else
X new_spells = 0;
X }
X return(learn);
X}
X
X
X/* Learn some prayers (Priest) -RAK- */
Xint learn_prayer()
X{
X register int i, j, k, l;
X int new_spell;
X int test_array[32];
X unsigned int spell_flag;
X int learn;
X register spell_type *s_ptr;
X
X i = 0;
X spell_flag = 0;
X do
X {
X if (inventory[i].tval == 91)
X spell_flag |= inventory[i].flags;
X i++;
X }
X while(i < inven_ctr);
X i = 0;
X while (spell_flag != 0)
X {
X j = bit_pos(&spell_flag);
X s_ptr = &magic_spell[py.misc.pclass][j];
X if (s_ptr->slevel <= py.misc.lev)
X if (!s_ptr->learned)
X {
X test_array[i] = j;
X i++;
X }
X }
X switch(wis_adj())
X {
X case 0: j = 0; break;
X case 1: j = 1; break;
X case 2: j = 1; break;
X case 3: j = 1; break;
X case 4: j = randint(2); break;
X case 5: j = randint(2); break;
X case 6: j = randint(3); break;
X case 7: j = randint(2)+1; break;
X }
X new_spell = 0;
X while ((i > 0) && (j > 0))
X {
X k = randint(i) - 1;
X magic_spell[py.misc.pclass][test_array[k]].learned = TRUE;
X new_spell++;
X for (l = k; l <= i-1; l++)
X test_array[l] = test_array[l+1];
X i--; /* One less spell to learn */
X j--; /* Learned one */
X }
X if (new_spell > 0)
X {
X if (new_spell > 1)
X msg_print("You learned new prayers!");
X else
X msg_print("You learned a new prayer!");
X /* make sure player see the message when game starts */
X if (py.misc.exp == 0) msg_print(" ");
X if (py.misc.mana == 0)
X {
X py.misc.mana = 1;
X py.misc.cmana = 1.0;
X }
X learn = TRUE;
X }
X else
X learn = FALSE;
X return(learn);
X}
X
X
X/* Gain some mana if you knows at least one spell -RAK- */
Xgain_mana(amount)
Xint amount;
X{
X register int i, new_mana;
X register int knows_spell;
X
X knows_spell = FALSE;
X for (i = 0; i < 31; i++)
X if (magic_spell[py.misc.pclass][i].learned)
X knows_spell = TRUE;
X if (knows_spell)
X {
X if (0x1 & py.misc.lev)
X switch(amount)
X {
X case 0: new_mana = 0; break;
X case 1: new_mana = 1; break;
X case 2: new_mana = 1; break;
X case 3: new_mana = 1; break;
X case 4: new_mana = 2; break;
X case 5: new_mana = 2; break;
X case 6: new_mana = 3; break;
X case 7: new_mana = 4; break;
X default: new_mana = 0; break;
X }
X else
X switch(amount)
X {
X case 0: new_mana = 0; break;
X case 1: new_mana = 1; break;
X case 2: new_mana = 1; break;
X case 3: new_mana = 2; break;
X case 4: new_mana = 2; break;
X case 5: new_mana = 3; break;
X case 6: new_mana = 3; break;
X case 7: new_mana = 4; break;
X default: new_mana = 0; break;
X }
X py.misc.mana += new_mana;
X py.misc.cmana += new_mana;
X }
X}
X
X
X/* Increases hit points and level -RAK- */
Xgain_level()
X{
X int nhp, dif_exp, need_exp;
X int redraw;
X vtype out_val;
X register struct misc *p_ptr;
X register class_type *c_ptr;
X
X p_ptr = &py.misc;
X nhp = get_hitdie();
X p_ptr->mhp += nhp;
X p_ptr->chp += (double)nhp;
X p_ptr->lev++;
X need_exp = (player_exp[p_ptr->lev-1] * p_ptr->expfact);
X if (py.misc.exp > need_exp)
X {
X /* lose some of the 'extra' exp when gain a level */
X dif_exp = py.misc.exp - need_exp;
X py.misc.exp = need_exp + (dif_exp / 2);
X }
X (void) strcpy(p_ptr->title, player_title[p_ptr->pclass][p_ptr->lev-1]);
X (void) sprintf(out_val, "Welcome to level %d.", (int)p_ptr->lev);
X msg_print(out_val);
X /* make sure player sees message, before learn_spell erases it */
X msg_print(" ");
X msg_flag = FALSE;
X prt_mhp();
X prt_chp();
X prt_level();
X prt_title();
X c_ptr = &class[p_ptr->pclass];
X if (c_ptr->mspell)
X {
X redraw = FALSE;
X (void) learn_spell(&redraw);
X if (redraw) draw_cave();
X gain_mana(int_adj());
X prt_cmana();
X }
X else if (c_ptr->pspell)
X {
X (void) learn_prayer();
X gain_mana(wis_adj());
X prt_cmana();
X }
X}
X
X/* Prints experience -RAK- */
Xprt_experience()
X{
X register struct misc *p_ptr;
X
X p_ptr = &py.misc;
X if (p_ptr->exp > player_max_exp)
X p_ptr->exp = player_max_exp;
X if (p_ptr->lev < MAX_PLAYER_LEVEL)
X {
X while ((player_exp[p_ptr->lev-1] * p_ptr->expfact) <= p_ptr->exp)
X gain_level();
X if (p_ptr->exp > p_ptr->max_exp)
X p_ptr->max_exp = p_ptr->exp;
X }
X prt_num("", py.misc.exp, 14, stat_column+6);
X}
X
X
X/* Inserts a string into a string */
Xinsert_str(object_str, mtc_str, insert)
Xchar *object_str, *mtc_str, *insert;
X{
X int obj_len;
X char *bound, *pc;
X register int i, mtc_len;
X register char *temp_obj, *temp_mtc;
X char out_val[80];
X
X mtc_len = strlen(mtc_str);
X obj_len = strlen(object_str);
X bound = object_str + obj_len - mtc_len;
X for (pc = object_str; pc <= bound; pc++)
X {
X temp_obj = pc;
X temp_mtc = mtc_str;
X for (i = 0; i < mtc_len; i++)
X if (*temp_obj++ != *temp_mtc++)
X break;
X if (i == mtc_len)
X break;
X }
X
X if (pc <= bound)
X {
X (void) strncpy(out_val, object_str, (pc-object_str));
X out_val[(pc-object_str)] = '\0';
X (void) strcat(out_val, insert);
X (void) strcat(out_val, (char *)(pc+mtc_len));
X (void) strcpy(object_str, out_val);
X }
X}
X
X
X/* Inserts a number into a string */
Xinsert_num(object_str, mtc_str, number, show_sign)
Xchar *object_str;
Xregister char *mtc_str;
Xint number;
Xint show_sign;
X{
X int pos, mlen;
X vtype str1, str2;
X register char *string, *tmp_str;
X int flag;
X
X flag = 1;
X tmp_str = object_str;
X do
X {
X string = index(tmp_str, mtc_str[0]);
X if (string == 0)
X flag = 0;
X else
X {
X flag = strncmp(string, mtc_str, strlen(mtc_str));
X if (flag)
X tmp_str = string+1;
X }
X }
X while (flag);
X if (string)
X pos = strlen(object_str) - strlen(string);
X else
X pos = -1;
X if (pos >= 0)
X {
X mlen = strlen(mtc_str);
X (void) strncpy(str1, object_str, pos);
X str1[pos] = '\0';
X (void) strcpy(str2, &object_str[pos+mlen]);
X if ((number >= 0) && (show_sign))
X (void) sprintf(object_str, "%s+%d%s", str1, number, str2);
X else
X (void) sprintf(object_str, "%s%d%s", str1, number, str2);
X }
X}
X
X
X/* Checks to see if user is a wizard -RAK- */
Xint check_pswd()
X{
X register int i;
X char x;
X char tpw[12];
X register int check;
X
X check = FALSE;
X if (getuid() != UID)
X return(FALSE);
X i = 0;
X tpw[0] = '\0';
X prt("Password : ", 0, 0);
X do
X {
X inkey(&x);
X switch(x)
X {
X case 10:
X case 13:
X break;
X default:
X tpw[i] = x;
X i++;
X break;
X }
X }
X while ((i != 12) && (x != 13) && (x != 10));
X tpw[i] = '\0';
X if (!strcmp(tpw, password1))
X {
X wizard1 = TRUE;
X check = TRUE;
X }
X else if (!strcmp(tpw, password2))
X {
X wizard1 = TRUE;
X wizard2 = TRUE;
X check = TRUE;
X }
X msg_flag = FALSE;
X erase_line(MSG_LINE, 0);
X return(check);
X}
X
X
X/* Weapon weight VS strength and dexterity -RAK- */
Xint attack_blows(weight, wtohit)
Xint weight;
Xint *wtohit;
X{
X register int adj_weight, blows;
X register struct stats *p_ptr;
X
X blows = 1;
X *wtohit = 0;
X p_ptr = &py.stats;
X if ((p_ptr->cstr*15) < weight)
X *wtohit = p_ptr->cstr*15 - weight;
X else
X {
X if (p_ptr->cdex < 10) blows = 1;
X else if (p_ptr->cdex < 19) blows = 2;
X else if (p_ptr->cdex < 68) blows = 3;
X else if (p_ptr->cdex < 108) blows = 4;
X else if (p_ptr->cdex < 118) blows = 5;
X else blows = 6;
X adj_weight = ((p_ptr->cstr*10)/weight);
X if (adj_weight < 2) blows = 1;
X else if (adj_weight < 3) blows = (blows/3.0) + 1;
X else if (adj_weight < 4) blows = (blows/2.5) + 1;
X else if (adj_weight < 5) blows = (blows/2.25) + 1;
X else if (adj_weight < 7) blows = (blows/2.00) + 1;
X else if (adj_weight < 9) blows = (blows/1.75) + 1;
X else blows = (blows/1.50) + 1;
X }
X return(blows);
X}
X
X
X/* Critical hits, Nasty way to die... -RAK- */
Xint critical_blow(weight, plus, dam)
Xregister int weight, plus, dam;
X{
X register int critical;
X
X critical = dam;
X /* Weight of weapon, plusses to hit, and character level all */
X /* contribute to the chance of a critical */
X if (randint(5000) <= (int)(weight+5*plus+3*py.misc.lev))
X {
X weight += randint(650);
X if (weight < 400)
X {
X critical = 2*dam + 5;
X msg_print("It was a good hit! (x2 damage)");
X }
X else if (weight < 700)
X {
X critical = 3*dam + 10;
X msg_print("It was an excellent hit! (x3 damage)");
X }
X else if (weight < 900)
X {
X critical = 4*dam + 15;
X msg_print("It was a superb hit! (x4 damage)");
X }
X else
X {
X critical = 5*dam + 20;
X msg_print("It was a *GREAT* hit! (x5 damage)");
X }
X }
X return(critical);
X}
X
X
X/* Given direction "dir", returns new row, column location -RAK- */
Xint move(dir, y, x)
Xint dir;
Xregister int *y, *x;
X{
X register int new_row, new_col;
X int bool;
X
X switch(dir)
X {
X case 1:
X new_row = *y + 1;
X new_col = *x - 1;
X break;
X case 2:
X new_row = *y + 1;
X new_col = *x;
X break;
X case 3:
X new_row = *y + 1;
X new_col = *x + 1;
X break;
X case 4:
X new_row = *y;
X new_col = *x - 1;
X break;
X case 5:
X new_row = *y;
X new_col = *x;
X break;
X case 6:
X new_row = *y;
X new_col = *x + 1;
X break;
X case 7:
X new_row = *y - 1;
X new_col = *x - 1;
X break;
X case 8:
X new_row = *y - 1;
X new_col = *x;
X break;
X case 9:
X new_row = *y - 1;
X new_col = *x + 1;
X break;
X }
X bool = FALSE;
X if ((new_row >= 0) && (new_row < cur_height))
X if ((new_col >= 0) && (new_col < cur_width))
X {
X *y = new_row;
X *x = new_col;
X bool = TRUE;
X }
X return(bool);
X}
X
X/* Saving throws for player character... -RAK- */
Xint player_saves(adjust)
Xint adjust;
X{
X if (randint(100) <= (py.misc.save + py.misc.lev + adjust))
X return(TRUE);
X else
X return(FALSE);
X}
X
X
X/* Init players with some belongings -RAK- */
Xchar_inven_init()
X{
X register int i, j;
X int dummy;
X
X /* this is needed for bash to work right, it can't hurt anyway */
X for (i = 0; i < INVEN_ARRAY_SIZE; i++)
X inventory[i] = blank_treasure;
X
X for (i = 0; i < 5; i++)
X {
X j = player_init[py.misc.pclass][i];
X inventory[INVEN_MAX] = inventory_init[j];
X inven_carry(&dummy);
X }
X}
END_OF_FILE
if test 42026 -ne `wc -c <'misc2.c'`; then
echo shar: \"'misc2.c'\" unpacked with wrong size!
fi
# end of 'misc2.c'
fi
if test -f 'types.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'types.h'\"
else
echo shar: Extracting \"'types.h'\" \(10578 characters\)
sed "s/^X//" >'types.h' <<'END_OF_FILE'
Xtypedef unsigned char byteint;
X#ifdef NO_SIGNED_CHARS
Xtypedef short bytlint;
X#else
Xtypedef char bytlint;
X#endif
Xtypedef unsigned short wordint;
Xtypedef short worlint;
X
Xtypedef char atype[17];
Xtypedef char btype[15];
Xtypedef char ctype[27];
Xtypedef char dtype[6];
Xtypedef char etype[35];
Xtypedef char ttype[80];
Xtypedef char vtype[80];
Xtypedef char stat_type[7];
X
Xtypedef struct creature_type
X{
X ctype name; /* Descrip of creature */
X unsigned int cmove; /* Bit field */
X unsigned int spells; /* Creature spells */
X wordint cdefense; /* Bit field */
X worlint sleep; /* Inactive counter */
X wordint mexp; /* Exp value for kill */
X byteint aaf; /* Area affect radius */
X byteint ac; /* AC */
X bytlint speed; /* Movement speed */
X char cchar; /* Character rep. */
X dtype hd; /* Creatures hit die */
X etype damage; /* Type attack and damage*/
X byteint level; /* Level of creature */
X} creature_type;
X
Xtypedef struct monster_type
X{
X worlint hp; /* Hit points */
X worlint csleep; /* Inactive counter */
X worlint cdis; /* Cur dis from player */
X wordint mptr; /* Pointer into creature */
X wordint nptr; /* Pointer to next block */
X bytlint cspeed; /* Movement speed */
X /* Note: FY and FX constrain dungeon size to 255 */
X byteint fy; /* Y Pointer into map */
X byteint fx; /* X Pointer into map */
X int stunned; /* Rounds stunned*/
X int ml; /* On if shown */
X int confused; /* On if confused*/
X} monster_type;
X
Xtypedef struct treasure_type
X{
X ttype name; /* Object name */
X byteint tval; /* Category number */
X char tchar; /* Character representation*/
X unsigned int flags; /* Special flags */
X int p1; /* Misc. use variable */
X int cost; /* Cost of item */
X int subval; /* Sub-category number */
X wordint weight; /* Weight */
X wordint number; /* Number of items */
X worlint tohit; /* Plusses to hit */
X worlint todam; /* Plusses to damage */
X worlint ac; /* Normal AC */
X worlint toac; /* Plusses to AC */
X dtype damage; /* Damage when hits */
X bytlint level; /* Level item found */
X} treasure_type;
X
Xtypedef struct player_type
X{
X struct misc
X {
X vtype name; /* Name of character */
X vtype race; /* Race of character */
X vtype sex; /* Sex of character */
X vtype title; /* Character's title */
X vtype tclass; /* Character's class */
X int max_exp; /* Max experience*/
X int exp; /* Cur experience */
X int au; /* Gold */
X wordint age; /* Characters age*/
X wordint ht; /* Height */
X wordint wt; /* Weight */
X wordint lev; /* Level */
X wordint max_lev; /* Max level explored*/
X worlint srh; /* Chance in search*/
X worlint fos; /* Frenq of search*/
X worlint bth; /* Base to hit */
X worlint bthb; /* BTH with bows */
X worlint mana; /* Mana points */
X worlint mhp; /* Max hit pts */
X worlint ptohit; /* Plusses to hit */
X worlint ptodam; /* Plusses to dam */
X worlint pac; /* Total AC */
X worlint ptoac; /* Magical AC */
X worlint dis_th; /* Display +ToHit*/
X worlint dis_td; /* Display +ToDam*/
X worlint dis_ac; /* Display +ToAC */
X worlint dis_tac; /* Display +ToTAC*/
X worlint disarm; /* % to Disarm */
X worlint save; /* Saving throw */
X worlint sc; /* Social Class */
X byteint pclass; /* # of class */
X byteint prace; /* # of race */
X byteint hitdie; /* Char hit die */
X bytlint stl; /* Stealth factor*/
X double expfact; /* Experience factor*/
X double cmana; /* Cur mana pts */
X double chp; /* Cur hit pts */
X vtype history[5]; /* History record*/
X } misc;
X struct stats
X {
X byteint str; /* Max strength */
X byteint cstr; /* Current strength */
X byteint dex; /* Max dexterity */
X byteint cdex; /* Current dexterity */
X byteint con; /* Max constitution */
X byteint ccon; /* Current constitution*/
X byteint intel; /* Max intelligence */
X byteint cint; /* Current intelligence*/
X byteint wis; /* Max wisdom */
X byteint cwis; /* Current wisdom */
X byteint chr; /* Max charisma */
X byteint cchr; /* Current charisma */
X } stats;
X struct flags
X {
X unsigned int status; /* Status of player */
X int rest; /* Rest counter */
X int blind; /* Blindness counter */
X int paralysis; /* Paralysis counter */
X int confused; /* Confusion counter */
X int food; /* Food counter */
X int food_digested; /* Food per round */
X int protection; /* Protection fr. evil */
X int speed; /* Cur speed adjust */
X int fast; /* Temp speed change */
X int slow; /* Temp speed change */
X int afraid; /* Fear */
X int poisoned; /* Poisoned */
X int image; /* Hallucinate */
X int protevil; /* Protect VS evil */
X int invuln; /* Increases AC */
X int hero; /* Heroism */
X int shero; /* Super Heroism */
X int blessed; /* Blessed */
X int resist_heat; /* Timed heat resist */
X int resist_cold; /* Timed cold resist */
X int detect_inv; /* Timed see invisible */
X int word_recall; /* Timed teleport level*/
X int see_infra; /* See warm creatures */
X int tim_infra; /* Timed infra vision */
X int see_inv; /* Can see invisible */
X int teleport; /* Random teleportation*/
X int free_act; /* Never paralyzed */
X int slow_digest; /* Lower food needs */
X int aggravate; /* Aggravate monsters */
X int fire_resist; /* Resistance to fire */
X int cold_resist; /* Resistance to cold */
X int acid_resist; /* Resistance to acid */
X int regenerate; /* Regenerate hit pts */
X int lght_resist; /* Resistance to light */
X int ffall; /* No damage falling */
X int sustain_str; /* Keep strength */
X int sustain_int; /* Keep intelligence */
X int sustain_wis; /* Keep wisdom */
X int sustain_con; /* Keep constitution */
X int sustain_dex; /* Keep dexterity */
X int sustain_chr; /* Keep charisma */
X int confuse_monster; /* Glowing hands... */
X } flags;
X} player_type;
X
Xtypedef struct spell_type
X{
X ctype sname;
X byteint slevel;
X byteint smana;
X wordint sexp;
X byteint sfail;
X int learned;
X} spell_type;
X
Xtypedef struct spl_rec
X{
X int splnum;
X int splchn;
X} spl_rec;
X
Xtypedef spl_rec spl_type[22];
X
Xtypedef struct race_type
X{
X vtype trace; /* Type of race */
X bytlint str_adj; /* adjustments */
X bytlint int_adj;
X bytlint wis_adj;
X bytlint dex_adj;
X bytlint con_adj;
X bytlint chr_adj;
X wordint b_age; /* Base age of character */
X wordint m_age; /* Maximum age of character */
X wordint m_b_ht; /* base height for males */
X wordint m_m_ht; /* mod height for males */
X wordint m_b_wt; /* base weight for males */
X wordint m_m_wt; /* mod weight for males */
X wordint f_b_ht; /* base height females */
X wordint f_m_ht; /* mod height for females */
X wordint f_b_wt; /* base weight for female */
X wordint f_m_wt; /* mod weight for females */
X double b_exp; /* Base experience factor */
X bytlint b_dis; /* base chance to disarm */
X bytlint srh; /* base chance for search */
X bytlint stl; /* Stealth of character */
X bytlint fos; /* frequency of auto search */
X bytlint bth; /* adj base chance to hit */
X bytlint bthb; /* adj base to hit with bows */
X bytlint bsav; /* Race base for saving throw */
X bytlint bhitdie; /* Base hit points for race */
X bytlint infra; /* See infra-red */
X unsigned int tclass; /* Bit field for class types */
X} race_type;
X
Xtypedef struct class_type
X{
X vtype title; /* type of class */
X double m_exp; /* Class experience factor */
X bytlint adj_hd; /* Adjust hit points */
X bytlint mdis; /* mod disarming traps */
X bytlint msrh; /* modifier to searching */
X bytlint mstl; /* modifier to stealth */
X bytlint mfos; /* modifier to freq-of-search */
X bytlint mbth; /* modifier to base to hit */
X bytlint mbthb; /* modifier to base to hit - bows*/
X bytlint msav; /* Class modifier to save */
X bytlint madj_str; /* Class modifier for strength*/
X bytlint madj_int; /* Class modifier for intelligence*/
X bytlint madj_wis; /* Class modifier for wisdom */
X bytlint madj_dex; /* Class modifier for dexterity*/
X bytlint madj_con; /* Class modifier for constitution*/
X bytlint madj_chr; /* Class modifier for charisma*/
X int pspell; /* class use priest spells */
X int mspell; /* class use mage spells */
X} class_type;
X
Xtypedef struct background_type
X{
X vtype info; /* History information */
X byteint roll; /* Die roll needed for history*/
X byteint chart; /* Table number */
X bytlint next; /* Pointer to next table */
X bytlint bonus; /* Bonus to the Social Class */
X} background_type;
X
Xtypedef struct floor_type
X{
X int ftval;
X int ftopen;
X} floor_type;
X
Xtypedef struct cave_type
X{
X byteint cptr;
X byteint tptr;
X int fval;
X int fopen;
X int fm; /* used for hidden objects */
X int pl;
X int tl;
X} cave_type;
X
Xtypedef struct owner_type
X{
X vtype owner_name;
X worlint max_cost;
X double max_inflate;
X double min_inflate;
X double haggle_per;
X byteint owner_race;
X byteint insult_max;
X} owner_type;
X
Xtypedef struct inven_record
X{
X int scost;
X treasure_type sitem;
X} inven_record;
X
Xtypedef struct store_type
X{
X worlint store_open;
X short insult_cur;
X byteint owner;
X byteint store_ctr;
X inven_record store_inven[STORE_INVEN_MAX];
X} store_type;
X
Xtypedef struct high_scores
X{
X long int points;
X wordint lev;
X wordint max_lev;
X worlint mhp;
X double chp;
X int uid;
X int dun_level;
X char sex;
X vtype name;
X vtype died_from;
X byteint pclass;
X byteint prace;
X} high_scores;
END_OF_FILE
if test 10578 -ne `wc -c <'types.h'`; then
echo shar: \"'types.h'\" unpacked with wrong size!
fi
# end of 'types.h'
fi
echo shar: End of archive 6 \(of 18\).
cp /dev/null ark6isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 18 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0