games-request@tekred.TEK.COM (11/05/87)
Submitted by: "James E. Wilson" <wilson@ji.berkeley.edu>
Comp.sources.games: Volume 2, Issue 73
Archive-name: umoria/Part08
#! /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 8 (of 16)."
# Contents: dungeon.c wizard.c
# Wrapped by billr@tekred on Wed Nov 4 09:59:53 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f dungeon.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"dungeon.c\"
else
echo shar: Extracting \"dungeon.c\" \(41414 characters\)
sed "s/^X//" >dungeon.c <<'END_OF_dungeon.c'
X#include <stdio.h>
X#ifdef USG
X#include <string.h>
X#else
X#include <strings.h>
X#endif
X
X#include "constants.h"
X#include "types.h"
X#include "externs.h"
X
X#ifdef sun /* correct SUN stupidity in the stdio.h file */
Xchar *sprintf();
X#endif
X
X#ifdef USG
Xunsigned sleep();
X#endif
X
X#ifdef ultrix
Xvoid sleep();
X#endif
X
X/* global flags */
Xint moria_flag; /* Next level when true */
Xint search_flag; /* Player is searching */
Xint teleport_flag; /* Handle teleport traps */
Xint player_light; /* Player carrying light */
Xint cave_flag; /* used in get_panel */
Xint light_flag; /* used in move_light */
X
X/* Moria game module -RAK- */
X/* The code in this section has gone through many revisions, and */
X/* some of it could stand some more hard work... -RAK- */
Xdungeon()
X{
X int old_chp, old_cmana; /* Detect change */
X double regen_amount; /* Regenerate hp and mana*/
X char command; /* Last command */
X int save_msg_flag; /* Msg flag after INKEY */
X struct misc *p_ptr;
X treasure_type *i_ptr;
X struct flags *f_ptr;
X int set_floor();
X
X /* Main procedure for dungeon... -RAK- */
X /* Note: There is a lot of preliminary magic going on here at first*/
X
X /* Check light status for setup */
X i_ptr = &inventory[32];
X if (i_ptr->p1 > 0)
X player_light = TRUE;
X else
X player_light = FALSE;
X /* Check for a maximum level */
X p_ptr = &py.misc;
X if (dun_level > p_ptr->max_lev) p_ptr->max_lev = dun_level;
X /* Set up the character co-ords */
X if ((char_row == -1) || (char_col == -1))
X new_spot(&char_row, &char_col);
X /* Reset flags and initialize variables */
X moria_flag = FALSE;
X cave_flag = FALSE;
X find_flag = FALSE;
X search_flag = FALSE;
X teleport_flag = FALSE;
X mon_tot_mult = 0;
X cave[char_row][char_col].cptr = 1;
X old_chp = (int)py.misc.chp;
X old_cmana = (int)py.misc.cmana;
X /* Light up the area around character */
X move_char(5);
X /* Light, but do not move critters */
X creatures(FALSE);
X /* Print the depth */
X prt_depth();
X
X /* Loop until dead, or new level */
X do
X {
X /* Increment turn counter */
X turn++;
X /* Check for game hours */
X if (!wizard1)
X if ((turn % 250) == 1)
X if (!check_time())
X if (closing_flag > 4)
X {
X if (search_flag)
X search_off();
X if (py.flags.rest > 0)
X rest_off();
X find_flag = FALSE;
X msg_print("The gates to Moria are now closed.");
X msg_print("");
X do
X {
X save_char(TRUE, FALSE);
X }
X while (TRUE);
X }
X else
X {
X if (search_flag)
X search_off();
X if (py.flags.rest > 0)
X rest_off();
X find_flag = FALSE;
X move_char(5);
X closing_flag++;
X msg_print("The gates to Moria are closing...");
X msg_print("Please finish up or save your game.");
X msg_print("");
X }
X
X /* Check for creature generation */
X if (randint(MAX_MALLOC_CHANCE) == 1)
X alloc_monster(set_floor, 1, MAX_SIGHT, FALSE);
X /* Screen may need updating, used mostly for stats*/
X if (print_stat != 0)
X {
X if (0x0001 & print_stat)
X prt_strength();
X if (0x0002 & print_stat)
X prt_dexterity();
X if (0x0004 & print_stat)
X prt_constitution();
X if (0x0008 & print_stat)
X prt_intelligence();
X if (0x0010 & print_stat)
X prt_wisdom();
X if (0x0020 & print_stat)
X prt_charisma();
X if (0x0040 & print_stat)
X prt_pac();
X if (0x0100 & print_stat)
X prt_mhp();
X if (0x0200 & print_stat)
X prt_title();
X if (0x0400 & print_stat)
X prt_level();
X }
X /* Check light status */
X i_ptr = &inventory[32];
X if (player_light)
X if (i_ptr->p1 > 0)
X {
X i_ptr->p1--;
X if (i_ptr->p1 == 0)
X {
X msg_print("Your light has gone out!");
X player_light = FALSE;
X find_flag = FALSE;
X move_light(char_row, char_col, char_row, char_col);
X }
X else if (i_ptr->p1 < 40)
X if (randint(5) == 1)
X {
X if (find_flag)
X {
X find_flag = FALSE;
X move_light(char_row, char_col, char_row, char_col);
X }
X msg_print("Your light is growing faint.");
X }
X }
X else
X {
X player_light = FALSE;
X find_flag = FALSE;
X move_light(char_row, char_col, char_row, char_col);
X }
X else if (i_ptr->p1 > 0)
X {
X i_ptr->p1--;
X player_light = TRUE;
X move_light(char_row, char_col, char_row, char_col);
X }
X
X /* Update counters and messages */
X f_ptr = &py.flags;
X /* Check food status */
X regen_amount = PLAYER_REGEN_NORMAL;
X if (f_ptr->food < PLAYER_FOOD_ALERT)
X {
X if (f_ptr->food < PLAYER_FOOD_WEAK)
X {
X if (f_ptr->food < 0)
X regen_amount = 0;
X else if (f_ptr->food < PLAYER_FOOD_FAINT)
X regen_amount = PLAYER_REGEN_FAINT;
X else if (f_ptr->food < PLAYER_FOOD_WEAK)
X regen_amount = PLAYER_REGEN_WEAK;
X if ((0x00000002 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000003;
X msg_print("You are getting weak from hunger.");
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X prt_hunger();
X }
X if (f_ptr->food < PLAYER_FOOD_FAINT)
X if (randint(8) == 1)
X {
X f_ptr->paralysis += randint(5);
X msg_print("You faint from the lack of food.");
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X }
X else
X {
X if ((0x00000001 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000001;
X msg_print("You are getting hungry.");
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X prt_hunger();
X }
X }
X }
X /* Food consumption */
X /* Note: Speeded up characters really burn up the food! */
X if (f_ptr->speed < 0)
X f_ptr->food += -(f_ptr->speed*f_ptr->speed) -
X f_ptr->food_digested;
X else
X f_ptr->food -= f_ptr->food_digested;
X /* Regenerate */
X p_ptr = &py.misc;
X if (f_ptr->regenerate) regen_amount *= 1.5;
X if (f_ptr->rest > 0) regen_amount *= 2;
X if (py.flags.poisoned < 1)
X if (p_ptr->chp < p_ptr->mhp)
X regenhp(regen_amount);
X if (p_ptr->cmana < p_ptr->mana)
X regenmana(regen_amount);
X /* Blindness */
X if (f_ptr->blind > 0)
X {
X if ((0x00000004 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000004;
X prt_map();
X prt_blind();
X if (search_flag)
X search_off();
X }
X f_ptr->blind--;
X if (f_ptr->blind == 0)
X {
X f_ptr->status &= 0xFFFFFFFB;
X prt_blind();
X prt_map();
X msg_print("The veil of darkness lifts.");
X if (find_flag)
X {
X find_flag = FALSE;
X }
X /* turn light back on */
X move_char(5);
X }
X }
X /* Confusion */
X if (f_ptr->confused > 0)
X {
X if ((0x00000008 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000008;
X prt_confused();
X }
X f_ptr->confused--;
X if (f_ptr->confused == 0)
X {
X f_ptr->status &= 0xFFFFFFF7;
X prt_confused();
X msg_print("You feel less confused now.");
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X }
X /* Afraid */
X if (f_ptr->afraid > 0)
X {
X if ((0x00000010 & f_ptr->status) == 0)
X {
X if ((f_ptr->shero+f_ptr->hero) > 0)
X f_ptr->afraid = 0;
X else
X {
X f_ptr->status |= 0x00000010;
X prt_afraid();
X }
X }
X else if ((f_ptr->shero+f_ptr->hero) > 0)
X f_ptr->afraid = 1;
X f_ptr->afraid--;
X if (f_ptr->afraid == 0)
X {
X f_ptr->status &= 0xFFFFFFEF;
X prt_afraid();
X msg_print("You feel bolder now.");
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X }
X /* Poisoned */
X if (f_ptr->poisoned > 0)
X {
X if ((0x00000020 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000020;
X prt_poisoned();
X }
X f_ptr->poisoned--;
X if (f_ptr->poisoned == 0)
X {
X f_ptr->status &= 0xFFFFFFDF;
X prt_poisoned();
X msg_print("You feel better.");
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X else
X {
X switch(con_adj())
X {
X case -4:
X take_hit(4, "poison.");
X break;
X case -3: case -2:
X take_hit(3, "poison.");
X break;
X case -1:
X take_hit(2, "poison.");
X break;
X case 0:
X take_hit(1, "poison.");
X break;
X case 1: case 2: case 3:
X if ((turn % 2) == 0)
X take_hit(1, "poison.");
X break;
X case 4: case 5:
X if ((turn % 3) == 0)
X take_hit(1, "poison.");
X break;
X case 6:
X if ((turn % 4) == 0)
X take_hit(1, "poison.");
X break;
X }
X }
X }
X /* Fast */
X if (f_ptr->fast > 0)
X {
X if ((0x00000040 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000040;
X msg_print("You feel yourself moving faster.");
X change_speed(-1);
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X f_ptr->fast--;
X if (f_ptr->fast == 0)
X {
X f_ptr->status &= 0xFFFFFFBF;
X msg_print("You feel yourself slow down.");
X change_speed(1);
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X }
X /* Slow */
X if (f_ptr->slow > 0)
X {
X if ((0x00000080 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00000080;
X msg_print("You feel yourself moving slower.");
X change_speed(1);
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X f_ptr->slow--;
X if (f_ptr->slow == 0)
X {
X f_ptr->status &= 0xFFFFFF7F;
X msg_print("You feel yourself speed up.");
X change_speed(-1);
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X }
X }
X /* Resting is over? */
X if (f_ptr->rest > 0)
X {
X /* Hibernate every 20 iterations so that process does */
X /* not eat up system... */
X /* NOTE: Remove comments for VMS version 4.0 or greater*/
X /* INKEY_DELAY takes care of hibernation for */
X /* VMS 3.7 or less */
X if ((f_ptr->rest % 20) == 1) (void) sleep(1);
X f_ptr->rest--;
X /* Test for any key being hit to abort rest. Also, */
X /* this will do a PUT_QIO which updates the screen... */
X /* One more side benefit; since inkey_delay hibernates */
X /* small amount before executing, this makes resting */
X /* less CPU intensive... */
X/* inkey_delay(&command, 0); */
X put_qio();
X if (f_ptr->rest == 0) /* Resting over */
X rest_off();
X/* else if (command != '\0') */ /* Resting aborted */
X/* rest_off(); */
X }
X /* Hallucinating? (Random characters appear!)*/
X if (f_ptr->image > 0)
X {
X f_ptr->image--;
X if (f_ptr->image == 0)
X draw_cave();
X }
X /* Paralysis */
X if (f_ptr->paralysis > 0)
X {
X f_ptr->paralysis--;
X if (f_ptr->rest > 0)
X rest_off();
X if (search_flag)
X search_off();
X }
X /* Protection from evil counter*/
X if (f_ptr->protevil > 0) f_ptr->protevil--;
X /* Invulnerability */
X if (f_ptr->invuln > 0)
X {
X if ((0x00001000 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00001000;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X msg_print("Your skin turns into steel!");
X py.misc.pac += 100;
X py.misc.dis_ac += 100;
X prt_pac();
X }
X f_ptr->invuln--;
X if (f_ptr->invuln == 0)
X {
X f_ptr->status &= 0xFFFFEFFF;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X msg_print("Your skin returns to normal...");
X py.misc.pac -= 100;
X py.misc.dis_ac -= 100;
X prt_pac();
X }
X }
X /* Heroism */
X if (f_ptr->hero > 0)
X {
X if ((0x00002000 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00002000;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X p_ptr = &py.misc;
X p_ptr->mhp += 10;
X p_ptr->chp += 10.0;
X p_ptr->bth += 12;
X p_ptr->bthb+= 12;
X msg_print("You feel like a HERO!");
X prt_mhp();
X }
X f_ptr->hero--;
X if (f_ptr->hero == 0)
X {
X f_ptr->status &= 0xFFFFDFFF;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X p_ptr = &py.misc;
X p_ptr->mhp -= 10;
X if (p_ptr->chp > p_ptr->mhp) p_ptr->chp = p_ptr->mhp;
X p_ptr->bth -= 12;
X p_ptr->bthb-= 12;
X msg_print("The heroism wears off.");
X prt_mhp();
X }
X }
X /* Super Heroism */
X if (f_ptr->shero > 0)
X {
X if ((0x00004000 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00004000;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X p_ptr = &py.misc;
X p_ptr->mhp += 20;
X p_ptr->chp += 20.0;
X p_ptr->bth += 24;
X p_ptr->bthb+= 24;
X msg_print("You feel like a SUPER HERO!");
X prt_mhp();
X }
X f_ptr->shero--;
X if (f_ptr->shero == 0)
X {
X f_ptr->status &= 0xFFFFBFFF;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X p_ptr = &py.misc;
X p_ptr->mhp -= 20;
X if (p_ptr->chp > p_ptr->mhp) p_ptr->chp = p_ptr->mhp;
X p_ptr->bth -= 24;
X p_ptr->bthb-= 24;
X msg_print("The super heroism wears off.");
X prt_mhp();
X }
X }
X /* Blessed */
X if (f_ptr->blessed > 0)
X {
X if ((0x00008000 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00008000;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X p_ptr = &py.misc;
X p_ptr->bth += 5;
X p_ptr->bthb+= 5;
X p_ptr->pac += 2;
X p_ptr->dis_ac+= 2;
X msg_print("You feel righteous!");
X prt_mhp();
X prt_pac();
X }
X f_ptr->blessed--;
X if (f_ptr->blessed == 0)
X {
X f_ptr->status &= 0xFFFF7FFF;
X if (find_flag)
X {
X find_flag = FALSE;
X move_char(5);
X }
X p_ptr = &py.misc;
X p_ptr->bth -= 5;
X p_ptr->bthb-= 5;
X p_ptr->pac -= 2;
X p_ptr->dis_ac -= 2;
X msg_print("The prayer has expired.");
X prt_mhp();
X prt_pac();
X }
X }
X /* Resist Heat */
X if (f_ptr->resist_heat > 0) f_ptr->resist_heat--;
X /* Resist Cold */
X if (f_ptr->resist_cold > 0) f_ptr->resist_cold--;
X /* Detect Invisible */
X if (f_ptr->detect_inv > 0)
X {
X if ((0x00010000 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00010000;
X f_ptr->see_inv = TRUE;
X }
X f_ptr->detect_inv--;
X if (f_ptr->detect_inv == 0)
X {
X f_ptr->status &= 0xFFFEFFFF;
X f_ptr->see_inv = FALSE;
X py_bonuses(blank_treasure, 0);
X }
X }
X /* Timed infra-vision */
X if (f_ptr->tim_infra > 0)
X {
X if ((0x00020000 & f_ptr->status) == 0)
X {
X f_ptr->status |= 0x00020000;
X f_ptr->see_infra++;
X }
X f_ptr->tim_infra--;
X if (f_ptr->tim_infra == 0)
X {
X f_ptr->status &= 0xFFFDFFFF;
X f_ptr->see_infra--;
X }
X }
X /* Word-of-Recall Note: Word-of-Recall is a delayed action */
X if (f_ptr->word_recall > 0)
X if (f_ptr->word_recall == 1)
X {
X if (dun_level > 0)
X {
X msg_print("You feel yourself yanked upwards!");
X dun_level = 0;
X }
X else if (py.misc.max_lev != 0)
X {
X msg_print("You feel yourself yanked downwards!");
X dun_level = py.misc.max_lev;
X }
X moria_flag = TRUE;
X f_ptr->paralysis++;
X f_ptr->word_recall = 0;
X }
X else
X f_ptr->word_recall--;
X
X /* Check hit points for adjusting... */
X p_ptr = &py.misc;
X if (!find_flag)
X if (py.flags.rest < 1)
X {
X if (old_chp != (int)(p_ptr->chp))
X {
X if (p_ptr->chp > p_ptr->mhp)
X p_ptr->chp = (double)p_ptr->mhp;
X prt_chp();
X old_chp = (int)p_ptr->chp;
X }
X if (old_cmana != (int)(p_ptr->cmana))
X {
X if (p_ptr->cmana > p_ptr->mana)
X p_ptr->cmana = (double)p_ptr->mana;
X prt_cmana();
X old_cmana = (int)p_ptr->cmana;
X }
X }
X
X if ((py.flags.paralysis < 1) && /* Accept a command? */
X (py.flags.rest < 1) &&
X (!death))
X /* Accept a command and execute it */
X {
X do
X {
X print_stat = 0;
X reset_flag = FALSE;
X /* Random teleportation */
X if (py.flags.teleport)
X if (randint(100) == 1)
X {
X find_flag = FALSE;
X teleport(40);
X }
X if (!find_flag)
X {
X print("", char_row, char_col);
X save_msg_flag = msg_flag;
X do
X {
X inkey(&command);
X }
X while (command == ' ');
X if (save_msg_flag) erase_line(msg_line, msg_line);
X global_com_val = (command);
X }
X /* Commands are executed in following subroutines */
X if (key_bindings == ORIGINAL)
X original_commands(&global_com_val);
X else
X rogue_like_commands(&global_com_val);
X /* End of commands */
X }
X while ((reset_flag) && (!moria_flag));
X }
X /* Teleport? */
X if (teleport_flag) teleport(100);
X /* Move the creatures */
X if (!moria_flag) creatures(TRUE);
X /* Exit when moria_flag is set */
X }
X while (!moria_flag);
X if (search_flag) search_off(); /* Fixed "SLOW" bug; 06-11-86 RAK */
X}
X
X
Xoriginal_commands(com_val)
Xint *com_val;
X{
X int y, x, dir_val;
X char command;
X int i;
X vtype out_val, tmp_str;
X struct stats *s_ptr;
X struct flags *f_ptr;
X int set_floor();
X
X switch(*com_val)
X {
X case 0: case 11: /*^K == exit */
X flush();
X if (get_com("Enter 'Q' to quit", &command))
X switch(command)
X {
X case 'q': case 'Q':
X moria_flag = TRUE;
X death = TRUE;
X /* need dot on the end to be consistent with creature.c */
X (void) strcpy(died_from, "Quitting.");
X break;
X default:
X break;
X }
X reset_flag = TRUE;
X break;
X case 13: /*^M == repeat */
X msg_print(old_msg);
X reset_flag = TRUE;
X break;
X case 16:
X if (wizard1) /*^P == password*/
X {
X msg_print("Wizard mode off.");
X wizard1 = FALSE;
X wizard2 = FALSE;
X reset_flag = TRUE;
X }
X else
X {
X if (check_pswd())
X {
X msg_print("Wizard mode on.");
X }
X reset_flag = TRUE;
X }
X break;
X case 18: /*^R == redraw */
X really_clear_screen();
X draw_cave();
X reset_flag = TRUE;
X break;
X case 24: /*^Z == save */
X if (total_winner)
X {
X msg_print("You are a Total Winner, your character must be retired...");
X msg_print("Use <Control>-K to when you are ready to quit.");
X }
X else
X {
X if (search_flag) search_off();
X save_char(TRUE, FALSE);
X }
X break;
X case 32: /*SPACE do nothing */
X reset_flag = TRUE;
X break;
X case '!': /*! == Shell */
X clear_screen(0, 0);
X prt("[Entering shell, type 'exit' to resume your game]\n",0,0);
X shell_out();
X clear_screen(0, 0);
X draw_cave();
X reset_flag = TRUE;
X break;
X case 46: /*. == find */
X y = char_row;
X x = char_col;
X if (get_dir("Which direction?", &dir_val, com_val, &y, &x))
X {
X find_flag = TRUE;
X move_char(dir_val);
X }
X break;
X case 47: /* / == identify */
X ident_char();
X reset_flag = TRUE;
X break;
X case 49:
X move_char(*com_val - 48); /* Move dir 1 */
X break;
X case 50:
X move_char(*com_val - 48); /* Move dir 2 */
X break;
X case 51:
X move_char(*com_val - 48); /* Move dir 3 */
X break;
X case 52:
X move_char(*com_val - 48); /* Move dir 4 */
X break;
X case 53: /* Rest one turn */
X move_char(*com_val - 48);
X (void) sleep(0); /* Sleep 1/10 a second*/
X flush();
X break;
X case 54:
X move_char(*com_val - 48); /* Move dir 6 */
X break;
X case 55:
X move_char(*com_val - 48); /* Move dir 7 */
X break;
X case 56:
X move_char(*com_val - 48); /* Move dir 8 */
X break;
X case 57:
X move_char(*com_val - 48); /* Move dir 9 */
X break;
X case 60:
X go_up(); /*< == go up */
X break;
X case 62:
X go_down(); /*> == go down */
X break;
X case 63: /*? == help */
X original_help();
X reset_flag = TRUE; /* Free move */
X break;
X /* case 65: /* Debug feature for weight
X x = 0;
X for (i = 0; i < INVEN_MAX; i++)
X {
X i_ptr = &inventory[i];
X x += i_ptr->weight*i_ptr->number;
X (void) sprintf(out_val, "%d | %d", inven_weight, x);
X msg_print(out_val);
X }
X break; */
X case 66:
X bash(); /*B == bash */
X break;
X case 67: /*C == character*/
X if (get_com("Print to file? (Y/N)", &command))
X switch(command)
X {
X case 'y': case 'Y':
X file_character();
X break;
X case 'n': case 'N':
X change_name();
X draw_cave();
X break;
X default:
X break;
X }
X reset_flag = TRUE; /* Free move */
X break;
X case 68:
X disarm_trap(); /*D == disarm */
X break;
X case 69:
X eat(); /*E == eat */
X break;
X case 70:
X refill_lamp(); /*F == refill */
X break;
X case 76: /*L == location */
X reset_flag = TRUE; /* Free move */
X if ((py.flags.blind > 0) || (no_light()))
X msg_print("You can't see your map.");
X else
X {
X (void) sprintf(out_val,
X "Section [%d,%d]; Location == [%d,%d]",
X (((char_row-1)/OUTPAGE_HEIGHT)+1),
X (((char_col-1)/OUTPAGE_WIDTH )+1),
X char_row, char_col);
X msg_print(out_val);
X }
X break;
X case 80: /*P == print map*/
X reset_flag = TRUE; /* Free move */
X if ((py.flags.blind > 0) || (no_light()))
X msg_print("You can't see to draw a map.");
X else
X print_map();
X break;
X case 82:
X rest(); /*R == rest */
X break;
X case 83:
X if (search_flag) /*S == srh mode */
X {
X search_off();
X reset_flag = TRUE; /* Free move */
X }
X else if (py.flags.blind > 0)
X msg_print("You are incapable of searching while blind.");
X else
X {
X search_on();
X reset_flag = TRUE; /* Free move */
X }
X break;
X case 84:
X y = char_row;
X x = char_col;
X if (get_dir("Which direction?", &dir_val, com_val, &y, &x))
X {
X tunnel(y, x); /*T == tunnel */
X }
X break;
X case 97:
X aim(); /*a == aim */
X break;
X case 98:
X examine_book(); /*b == browse */
X break;
X case 99:
X closeobject(); /*c == close */
X break;
X case 100:
X drop(); /*d == drop */
X break;
X case 101: /*e == equipment*/
X reset_flag = TRUE; /* Free move */
X if (inven_command('e', 0, 0)) draw_cave();
X break;
X case 102:
X throw_object(); /*f == throw */
X break;
X /* case 104: /*h == moria hlp
X moria_help("");
X draw_cave();
X reset_flag = TRUE; /* Free move
X break; */
X case 105: /*i == inventory*/
X reset_flag = TRUE; /* Free move */
X if (inven_command('i', 0, 0)) draw_cave();
X break;
X case 106:
X jamdoor(); /*j == jam */
X break;
X case 108: /*l == look */
X look();
X reset_flag = TRUE; /* Free move */
X break;
X case 109:
X cast(); /*m == magick */
X break;
X case 111:
X openobject(); /*o == open */
X break;
X case 112:
X pray(); /*p == pray */
X break;
X case 113:
X quaff(); /*q == quaff */
X break;
X case 114:
X read_scroll(); /*r == read */
X break;
X case 115:
X if (py.flags.blind > 0) /*s == search */
X msg_print("You are incapable of searching while blind.");
X else
X search(char_row, char_col, py.misc.srh);
X break;
X case 116: /*t == unwear */
X reset_flag = TRUE;
X if (inven_command('t', 0, 0)) draw_cave();
X break;
X case 117:
X use(); /*u == use staff*/
X break;
X case 118:
X game_version(); /*v == version */
X break;
X case 119: /*w == wear */
X reset_flag = TRUE;
X if (inven_command('w', 0, 0)) draw_cave();
X break;
X case 120: /*x == exchange */
X reset_flag = TRUE;
X if (inven_command('x', 0, 0)) draw_cave();
X break;
X default:
X if (wizard1)
X {
X reset_flag = TRUE; /* Wizard commands are free moves*/
X switch(*com_val)
X {
X case 1: /*^A == Cure all*/
X (void) remove_curse();
X (void) cure_blindness();
X (void) cure_confusion();
X (void) cure_poison();
X (void) remove_fear();
X s_ptr = &py.stats;
X s_ptr->cstr = s_ptr->str;
X s_ptr->cint = s_ptr->intel;
X s_ptr->cwis = s_ptr->wis;
X s_ptr->cdex = s_ptr->dex;
X s_ptr->ccon = s_ptr->con;
X s_ptr->cchr = s_ptr->chr;
X f_ptr = &py.flags;
X if (f_ptr->slow > 1)
X f_ptr->slow = 1;
X if (f_ptr->image > 1)
X f_ptr->image = 1;
X put_qio();
X break;
X case 2:
X print_objects(); /*^B == objects */
X break;
X case 4: /*^D == up/down */
X prt("Go to which level (0 -1200) ? ", 0, 0);
X i = -1;
X if (get_string(tmp_str, 0, 30, 10))
X (void) sscanf(tmp_str, "%d", &i);
X if (i > -1)
X {
X dun_level = i;
X if (dun_level > 1200)
X dun_level = 1200;
X moria_flag = TRUE;
X }
X else
X erase_line(msg_line, msg_line);
X break;
X case 8:
X original_wizard_help(); /*^H == wizhelp */
X break;
X case 9:
X (void) ident_spell(); /*^I == identify*/
X break;
X case 14:
X print_monsters(); /*^N == mon map */
X break;
X case 12:
X wizard_light(); /*^L == wizlight*/
X break;
X case 20:
X teleport(100); /*^T == teleport*/
X break;
X case 22:
X restore_char(); /*^V == restore */
X prt_stat_block();
X moria_flag = TRUE;
X break;
X default:
X if (wizard2)
X switch(*com_val)
X {
X case 5:
X change_character(); /*^E == wizchar */
X break;
X case 6:
X (void) mass_genocide(); /*^F == genocide*/
X put_qio();
X break;
X case 7: /*^G == treasure*/
X alloc_object(set_floor, 5, 10);
X put_qio();
X break;
X case 10: /*^J == gain exp*/
X if (py.misc.exp == 0)
X py.misc.exp = 1;
X else
X py.misc.exp *= 2;
X prt_experience();
X break;
X case 21: /*^U == summon */
X y = char_row;
X x = char_col;
X (void) summon_monster(&y, &x, TRUE);
X creatures(FALSE);
X break;
X case 23:
X wizard_create(); /*^W == create */
X break;
X default:
X prt("Type '?' for help...", 0, 0);
X break;
X }
X else
X prt("Type '?' for help...", 0, 0);
X }
X }
X else
X {
X prt("Type '?' for help...", 0, 0);
X reset_flag = TRUE;
X }
X }
X}
X
X
Xrogue_like_commands(com_val)
Xint *com_val;
X{
X int y, x;
X char command;
X int i;
X vtype out_val, tmp_str;
X struct stats *s_ptr;
X struct flags *f_ptr;
X int set_floor();
X
X switch(*com_val)
X {
X case 0: case 'Q': /*Q == exit */
X flush();
X if (get_com("Do you really want to quit?", &command))
X switch(command)
X {
X case 'y': case 'Y':
X moria_flag = TRUE;
X death = TRUE;
X /* need dot on the end to be consistent with creature.c */
X (void) strcpy(died_from, "Quitting.");
X break;
X default:
X break;
X }
X reset_flag = TRUE;
X break;
X case 16: /*^P == repeat */
X msg_print(old_msg);
X reset_flag = TRUE;
X break;
X case 23:
X if (wizard1) /*^W == password*/
X {
X msg_print("Wizard mode off.");
X wizard1 = FALSE;
X wizard2 = FALSE;
X reset_flag = TRUE;
X }
X else
X {
X if (check_pswd())
X {
X msg_print("Wizard mode on.");
X }
X reset_flag = TRUE;
X }
X break;
X case 18: /*^R == redraw */
X really_clear_screen();
X draw_cave();
X reset_flag = TRUE;
X break;
X case 24: /*^X == save */
X if (total_winner)
X {
X msg_print("You are a Total Winner, your character must be retired...");
X msg_print("Use 'Q' to when you are ready to quit.");
X }
X else
X {
X if (search_flag) search_off();
X save_char(TRUE, FALSE);
X }
X break;
X case ' ': /*SPACE do nothing */
X reset_flag = TRUE;
X break;
X case '!': /*! == Shell */
X clear_screen(0, 0);
X prt("[Entering shell, type '^D' to resume your game]\n",0,0);
X shell_out();
X clear_screen(0, 0);
X draw_cave();
X reset_flag = TRUE;
X break;
X case 'b':
X move_char(1);
X break;
X case 'j':
X move_char(2);
X break;
X case 'n':
X move_char(3);
X break;
X case 'h':
X move_char(4);
X break;
X case 'l':
X move_char(6);
X break;
X case 'y':
X move_char(7);
X break;
X case 'k':
X move_char(8);
X break;
X case 'u':
X move_char(9);
X break;
X case 'B': /*. == find */
X find_flag = TRUE;
X move_char(1);
X break;
X case 'J': /*. == find */
X find_flag = TRUE;
X move_char(2);
X break;
X case 'N': /*. == find */
X find_flag = TRUE;
X move_char(3);
X break;
X case 'H': /*. == find */
X find_flag = TRUE;
X move_char(4);
X break;
X case 'L': /*. == find */
X find_flag = TRUE;
X move_char(6);
X break;
X case 'Y': /*. == find */
X find_flag = TRUE;
X move_char(7);
X break;
X case 'K': /*. == find */
X find_flag = TRUE;
X move_char(8);
X break;
X case 'U': /*. == find */
X find_flag = TRUE;
X move_char(9);
X break;
X case '/': /* / == identify */
X ident_char();
X reset_flag = TRUE;
X break;
X case '1':
X move_char(1); /* Move dir 1 */
X break;
X case '2':
X move_char(2); /* Move dir 2 */
X break;
X case '3':
X move_char(3); /* Move dir 3 */
X break;
X case '4':
X move_char(4); /* Move dir 4 */
X break;
X case '5': /* Rest one turn */
X case '.':
X move_char(5);
X (void) sleep(0); /* Sleep 1/10 a second*/
X flush();
X break;
X case '6':
X move_char(6); /* Move dir 6 */
X break;
X case '7':
X move_char(7); /* Move dir 7 */
X break;
X case '8':
X move_char(8); /* Move dir 8 */
X break;
X case '9':
X move_char(9); /* Move dir 9 */
X break;
X case '<':
X go_up(); /*< == go up */
X break;
X case '>':
X go_down(); /*> == go down */
X break;
X case '?': /*? == help */
X rogue_like_help();
X reset_flag = TRUE; /* Free move */
X break;
X /* case 65: /* Debug feature for weight
X x = 0;
X for (i = 0; i < INVEN_MAX; i++)
X {
X i_ptr = &inventory[i];
X x += i_ptr->weight*i_ptr->number;
X (void) sprintf(out_val, "%d | %d", inven_weight, x);
X msg_print(out_val);
X }
X break; */
X case 'f':
X bash(); /*f == bash */
X break;
X case 'C': /*C == character*/
X if (get_com("Print to file? (Y/N)", &command))
X switch(command)
X {
X case 'y': case 'Y':
X file_character();
X break;
X case 'n': case 'N':
X change_name();
X draw_cave();
X break;
X default:
X break;
X }
X reset_flag = TRUE; /* Free move */
X break;
X case 'D':
X disarm_trap(); /*D == disarm */
X break;
X case 'E':
X eat(); /*E == eat */
X break;
X case 'F':
X refill_lamp(); /*F == refill */
X break;
X case 'W': /*W == location */
X reset_flag = TRUE; /* Free move */
X if ((py.flags.blind > 0) || (no_light()))
X msg_print("You can't see your map.");
X else
X {
X (void) sprintf(out_val,
X "Section [%d,%d]; Location == [%d,%d]",
X (((char_row-1)/OUTPAGE_HEIGHT)+1),
X (((char_col-1)/OUTPAGE_WIDTH )+1),
X char_row, char_col);
X msg_print(out_val);
X }
X break;
X case 'M': /*M == print map*/
X reset_flag = TRUE; /* Free move */
X if ((py.flags.blind > 0) || (no_light()))
X msg_print("You can't see to draw a map.");
X else
X print_map();
X break;
X case 'R':
X rest(); /*R == rest */
X break;
X case '#':
X if (search_flag) /*^S == srh mode */
X {
X search_off();
X reset_flag = TRUE; /* Free move */
X }
X else if (py.flags.blind > 0)
X msg_print("You are incapable of searching while blind.");
X else
X {
X search_on();
X reset_flag = TRUE; /* Free move */
X }
X break;
X case 25: /* ^Y */
X x = char_row;
X y = char_col;
X (void) move(7, &x, &y);
X tunnel(x, y);
X break;
X case 11: /* ^K */
X x = char_row;
X y = char_col;
X (void) move(8, &x, &y);
X tunnel(x, y);
X break;
X case 21: /* ^U */
X x = char_row;
X y = char_col;
X (void) move(9, &x, &y);
X tunnel(x, y);
X break;
X case 12: /* ^L */
X x = char_row;
X y = char_col;
X (void) move(6, &x, &y);
X tunnel(x, y);
X break;
X case 14: /* ^N */
X x = char_row;
X y = char_col;
X (void) move(3, &x, &y);
X tunnel(x, y);
X break;
X case 10: /* ^J */
X x = char_row;
X y = char_col;
X (void) move(2, &x, &y);
X tunnel(x, y);
X break;
X case 2: /* ^B */
X x = char_row;
X y = char_col;
X (void) move(1, &x, &y);
X tunnel(x, y);
X break;
X case 8: /* ^H */
X x = char_row;
X y = char_col;
X (void) move(4, &x, &y);
X tunnel(x, y);
X break;
X case 'z':
X aim(); /*z == aim */
X break;
X case 'P':
X examine_book(); /*P == browse */
X break;
X case 'c':
X closeobject(); /*c == close */
X break;
X case 'd':
X drop(); /*d == drop */
X break;
X case 'e': /*e == equipment*/
X reset_flag = TRUE; /* Free move */
X if (inven_command('e', 0, 0)) draw_cave();
X break;
X case 't':
X throw_object(); /*t == throw */
X break;
X /* case 104: /*h == moria hlp
X moria_help("");
X draw_cave();
X reset_flag = TRUE; /* Free move
X break; */
X case 'i': /*i == inventory*/
X reset_flag = TRUE; /* Free move */
X if (inven_command('i', 0, 0)) draw_cave();
X break;
X case 'S':
X jamdoor(); /*S == jam */
X break;
X case 'x': /*l == look */
X look();
X reset_flag = TRUE; /* Free move */
X break;
X case 'm':
X cast(); /*m == magick */
X break;
X case 'o':
X openobject(); /*o == open */
X break;
X case 'p':
X pray(); /*p == pray */
X break;
X case 'q':
X quaff(); /*q == quaff */
X break;
X case 'r':
X read_scroll(); /*r == read */
X break;
X case 's':
X if (py.flags.blind > 0) /*s == search */
X msg_print("You are incapable of searching while blind.");
X else
X search(char_row, char_col, py.misc.srh);
X break;
X case 'T': /*T == unwear */
X reset_flag = TRUE;
X if (inven_command('t', 0, 0)) draw_cave();
X break;
X case 'Z':
X use(); /*Z == use staff*/
X break;
X case 'v':
X game_version(); /*v == version */
X break;
X case 'w': /*w == wear */
X reset_flag = TRUE;
X if (inven_command('w', 0, 0)) draw_cave();
X break;
X case 'X': /*x == exchange */
X reset_flag = TRUE;
X if (inven_command('x', 0, 0)) draw_cave();
X break;
X default:
X if (wizard1)
X {
X reset_flag = TRUE; /* Wizard commands are free moves*/
X switch(*com_val)
X {
X case 1: /*^A == Cure all*/
X (void) remove_curse();
X (void) cure_blindness();
X (void) cure_confusion();
X (void) cure_poison();
X (void) remove_fear();
X s_ptr = &py.stats;
X s_ptr->cstr = s_ptr->str;
X s_ptr->cint = s_ptr->intel;
X s_ptr->cwis = s_ptr->wis;
X s_ptr->cdex = s_ptr->dex;
X s_ptr->ccon = s_ptr->con;
X s_ptr->cchr = s_ptr->chr;
X f_ptr = &py.flags;
X if (f_ptr->slow > 1)
X f_ptr->slow = 1;
X if (f_ptr->image > 1)
X f_ptr->image = 1;
X put_qio();
X break;
X case 15:
X print_objects(); /*^O == objects */
X break;
X case 4: /*^D == up/down */
X prt("Go to which level (0 -1200) ? ", 0, 0);
X i = -1;
X if (get_string(tmp_str, 0, 30, 10))
X (void) sscanf(tmp_str, "%d", &i);
X if (i > -1)
X {
X dun_level = i;
X if (dun_level > 1200)
X dun_level = 1200;
X moria_flag = TRUE;
X }
X else
X erase_line(msg_line, msg_line);
X break;
X case 127: /* ^? DEL */
X rogue_like_wizard_help(); /*DEL == wizhelp */
X break;
X case 9:
X (void) ident_spell(); /*^I == identify*/
X break;
X case 13:
X print_monsters(); /*^M == mon map */
X break;
X case '*':
X wizard_light(); /*` == wizlight*/
X break;
X case 20:
X teleport(100); /*^T == teleport*/
X break;
X case 22:
X restore_char(); /*^V == restore */
X prt_stat_block();
X moria_flag = TRUE;
X break;
X default:
X if (wizard2)
X switch(*com_val)
X {
X case 5:
X change_character(); /*^E == wizchar */
X break;
X case 6:
X (void) mass_genocide(); /*^F == genocide*/
X put_qio();
X break;
X case 7: /*^G == treasure*/
X alloc_object(set_floor, 5, 10);
X put_qio();
X break;
X case '+': /*+ == gain exp*/
X if (py.misc.exp == 0)
X py.misc.exp = 1;
X else
X py.misc.exp *= 2;
X prt_experience();
X break;
X case 21: /*^U == summon */
X y = char_row;
X x = char_col;
X (void) summon_monster(&y, &x, TRUE);
X creatures(FALSE);
X break;
X case 17:
X wizard_create(); /*^Q == create */
X break;
X default:
X prt("Type '?' for help...", 0, 0);
X break;
X }
X else
X prt("Type '?' for help...", 0, 0);
X }
X }
X else
X {
X prt("Type '?' for help...", 0, 0);
X reset_flag = TRUE;
X }
X }
X}
END_OF_dungeon.c
if test 41414 -ne `wc -c <dungeon.c`; then
echo shar: \"dungeon.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f wizard.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"wizard.c\"
else
echo shar: Extracting \"wizard.c\" \(11177 characters\)
sed "s/^X//" >wizard.c <<'END_OF_wizard.c'
X#include <stdio.h>
X#ifdef USG
X#include <string.h>
X#else
X#include <strings.h>
X#endif
X
X#include "constants.h"
X#include "types.h"
X#include "externs.h"
X
X#ifdef sun /* correct SUN stupidity in the stdio.h file */
Xchar *sprintf();
X#endif
X
X
X/* Print Moria credits -RAK- */
Xgame_version()
X{
X vtype tmp_str;
X
X clear_screen(0, 0);
X (void) sprintf(tmp_str, " Moria Version %f", CUR_VERSION);
X put_buffer(tmp_str, 0, 0);
X put_buffer("Version 0.1 : 03/25/83", 1, 0);
X put_buffer("Version 1.0 : 05/01/84", 2, 0);
X put_buffer("Version 2.0 : 07/10/84", 3, 0);
X put_buffer("Version 3.0 : 11/20/84", 4, 0);
X put_buffer("Version 4.0 : 01/20/85", 5, 0);
X put_buffer("Modules :", 7, 0);
X put_buffer(" V1.0 Dungeon Generator - RAK", 8, 0);
X put_buffer(" Character Generator - RAK & JWT", 9, 0);
X put_buffer(" Moria Module - RAK", 10, 0);
X put_buffer(" Miscellaneous - RAK & JWT", 11, 0);
X put_buffer(" V2.0 Town Level & Misc - RAK", 12, 0);
X put_buffer(" V3.0 Internal Help & Misc - RAK", 13, 0);
X put_buffer(" V4.0 Source Release Version - RAK", 14, 0);
X put_buffer("Robert Alan Koeneke Jimmey Wayne Todd Jr.", 16, 0);
X put_buffer("Student/University of Oklahoma Student/University of Oklahoma",
X 17, 0);
X put_buffer("119 Crystal Bend 1912 Tiffany Dr.", 18, 0);
X put_buffer("Norman, OK 73069 Norman, OK 73071", 19, 0);
X put_buffer("(405)-321-2925 (405) 360-6792", 20, 0);
X pause_line(23);
X clear_screen(0, 0);
X put_buffer("UNIX MORIA Port by James E. Wilson", 2, 0);
X put_buffer(" wilson@ernie.Berkeley.EDU", 3, 0);
X put_buffer(" ucbvax!ucbernie!wilson", 4, 0);
X put_buffer("This version is based on the VMS version 4.8", 6, 0);
X put_buffer("but is no longer identical to the original VMS program.", 7, 0);
X put_buffer("Please use care when referring to this program.", 8, 0);
X put_buffer("Please call it 'wilson MORIA' or 'UNIX MORIA' or something", 9, 0);
X put_buffer("similar to avoid confusion.", 10, 0);
X pause_line(23);
X draw_cave();
X}
X
X
X/* Light up the dungeon -RAK- */
Xwizard_light()
X{
X int i, j, k, l;
X int flag;
X cave_type *c_ptr;
X
X if (cave[char_row][char_col].pl)
X flag = FALSE;
X else
X flag = TRUE;
X for (i = 0; i < cur_height; i++)
X for (j = 0; j < cur_width; j++)
X if (set_floor(cave[i][j].fval))
X for (k = i-1; k <= i+1; k++)
X for (l = j-1; l <= j+1; l++)
X {
X c_ptr = &cave[k][l];
X c_ptr->pl = flag;
X if (!flag)
X c_ptr->fm = FALSE;
X }
X prt_map();
X}
X
X
X/* Wizard routine for gaining on stats -RAK- */
Xchange_character()
X{
X int tmp_val;
X vtype tmp_str;
X struct stats *s_ptr;
X struct misc *m_ptr;
X
X s_ptr = &py.stats;
X prt("(3 - 118) Strength == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 2) && (tmp_val < 119))
X {
X s_ptr->str = tmp_val;
X s_ptr->cstr = tmp_val;
X prt_strength();
X }
X prt("(3 - 118) Intelligence == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 2) && (tmp_val < 119))
X {
X s_ptr->intel = tmp_val;
X s_ptr->cint = tmp_val;
X prt_intelligence();
X }
X prt("(3 - 118) Wisdom == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 2) && (tmp_val < 119))
X {
X s_ptr->wis = tmp_val;
X s_ptr->cwis = tmp_val;
X prt_wisdom();
X }
X prt("(3 - 118) Dexterity == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 2) && (tmp_val < 119))
X {
X s_ptr->dex = tmp_val;
X s_ptr->cdex = tmp_val;
X prt_dexterity();
X }
X prt("(3 - 118) Constitution == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 2) && (tmp_val < 119))
X {
X s_ptr->con = tmp_val;
X s_ptr->ccon = tmp_val;
X prt_constitution();
X }
X prt("(3 - 118) Charisma == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 2) && (tmp_val < 119))
X {
X s_ptr->chr = tmp_val;
X s_ptr->cchr = tmp_val;
X prt_charisma();
X }
X
X m_ptr = &py.misc;
X prt("(1 - 32767) Hit points == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -1;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > 0) && (tmp_val < 32768))
X {
X m_ptr->mhp = tmp_val;
X m_ptr->chp = (double)tmp_val;
X prt_mhp();
X prt_chp();
X }
X prt("(0 - 32767) Mana == ", 0, 0);
X (void) get_string(tmp_str, 0, 25, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 32768))
X {
X m_ptr->mana = tmp_val;
X m_ptr->cmana = (double)tmp_val;
X prt_cmana();
X }
X (void) sprintf(tmp_str, "Current==%d (0-200) Searching == ", m_ptr->srh);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 201))
X m_ptr->srh = tmp_val;
X (void) sprintf(tmp_str, "Current==%d (0-10) Stealth == ", m_ptr->stl);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 11))
X m_ptr->stl = tmp_val;
X (void) sprintf(tmp_str, "Current==%d (0-200) Disarming == ", m_ptr->disarm);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 201))
X m_ptr->disarm = tmp_val;
X (void) sprintf(tmp_str, "Current==%d (0-100) Save == ", m_ptr->save);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 201))
X m_ptr->save = tmp_val;
X (void) sprintf(tmp_str, "Current==%d (0-200) Base to hit == ", m_ptr->bth);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 201))
X m_ptr->bth = tmp_val;
X (void) sprintf(tmp_str, "Current==%d (0-200) Bows/Throwing == ",
X m_ptr->bthb);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if ((tmp_val > -1) && (tmp_val < 201))
X m_ptr->bthb = tmp_val;
X (void) sprintf(tmp_str, "Current==%d Gold == ", m_ptr->au);
X tmp_val = strlen(tmp_str);
X prt(tmp_str, 0, 0);
X (void) get_string(tmp_str, 0, tmp_val, 10);
X tmp_val = -999;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X if (tmp_val > -1)
X {
X m_ptr->au = tmp_val;
X prt_gold();
X }
X
X erase_line(msg_line, msg_line);
X py_bonuses(blank_treasure, 0);
X}
X
X
X/* Wizard routine for creating objects -RAK- */
Xwizard_create()
X{
X int tmp_val;
X vtype tmp_str;
X int flag;
X treasure_type *i_ptr;
X cave_type *c_ptr;
X char command;
X
X msg_print("Warning: This routine can cause fatal error.");
X msg_print(" ");
X msg_flag = FALSE;
X i_ptr = &inventory[INVEN_MAX];
X prt("Name : ", 0, 0);
X if (get_string(tmp_str, 0, 9, 40))
X (void) strcpy(i_ptr->name, tmp_str);
X else
X (void) strcpy(i_ptr->name, "& Wizard Object!");
X do
X {
X prt("Tval : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X flag = TRUE;
X switch(tmp_val)
X {
X case 1: case 13: case 15 : i_ptr->tchar = '~'; break;
X case 2: i_ptr->tchar = '&'; break;
X case 10: i_ptr->tchar = '{'; break;
X case 11: i_ptr->tchar = '{'; break;
X case 12: i_ptr->tchar = '{'; break;
X case 20: i_ptr->tchar = '}'; break;
X case 21: i_ptr->tchar = '/'; break;
X case 22: i_ptr->tchar = '\\'; break;
X case 23: i_ptr->tchar = '|'; break;
X case 25: i_ptr->tchar = '\\'; break;
X case 30: i_ptr->tchar = ']'; break;
X case 31: i_ptr->tchar = ']'; break;
X case 32: i_ptr->tchar = '('; break;
X case 33: i_ptr->tchar = ']'; break;
X case 34: i_ptr->tchar = ')'; break;
X case 35: i_ptr->tchar = '['; break;
X case 36: i_ptr->tchar = '('; break;
X case 40: i_ptr->tchar = '\''; break;
X case 45: i_ptr->tchar = '='; break;
X case 55: i_ptr->tchar = '_'; break;
X case 60: i_ptr->tchar = '-'; break;
X case 65: i_ptr->tchar = '-'; break;
X case 70: case 71: i_ptr->tchar = '?'; break;
X case 75: case 76: case 77: i_ptr->tchar = '!'; break;
X case 80: i_ptr->tchar = ','; break;
X case 90: i_ptr->tchar = '?'; break;
X case 91: i_ptr->tchar = '?'; break;
X default: flag = FALSE; break;
X }
X }
X while (!flag);
X i_ptr->tval = tmp_val;
X prt("Subval : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 1;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->subval = tmp_val;
X prt("Weight : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 1;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->weight = tmp_val;
X prt("Number : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 1;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->number = tmp_val;
X prt("Damage : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 5);
X (void) strcpy(i_ptr->damage, tmp_str);
X prt("+To hit: ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->tohit = tmp_val;
X prt("+To dam: ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->todam = tmp_val;
X prt("AC : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->ac = tmp_val;
X prt("+To AC : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->toac = tmp_val;
X prt("P1 : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->p1 = tmp_val;
X prt("Flags (In HEX): ", 0, 0);
X i_ptr->flags = get_hex_value(0, 16, 8);
X prt("Cost : ", 0, 0);
X (void) get_string(tmp_str, 0, 9, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->cost = tmp_val;
X
X prt("Level : ", 0, 0);
X (void) get_string(tmp_str, 0, 10, 10);
X tmp_val = 0;
X (void) sscanf(tmp_str, "%d", &tmp_val);
X i_ptr->level = tmp_val;
X
X if (get_com("Allocate? (Y/N)", &command))
X switch(command)
X {
X case 'y': case 'Y':
X popt(&tmp_val);
X t_list[tmp_val] = inventory[INVEN_MAX];
X c_ptr = &cave[char_row][char_col];
X if (c_ptr->tptr != 0)
X (void) delete_object(char_row, char_col);
X c_ptr->tptr = tmp_val;
X msg_print("Allocated...");
X break;
X default:
X msg_print("Aborted...");
X break;
X }
X inventory[INVEN_MAX] = blank_treasure;
X}
END_OF_wizard.c
if test 11177 -ne `wc -c <wizard.c`; then
echo shar: \"wizard.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 8 \(of 16\).
cp /dev/null ark8isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 16 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