-+-+-+-+-+-+-+-+ START OF PART 12 -+-+-+-+-+-+-+-+ Xstore2.obj : constant.h, types.h, externs.h, config.h Xtables.obj : constant.h, types.h, config.h Xtreasure.obj : constant.h, types.h, config.h Xvariable.obj : constant.h, types.h, config.h Xwands.obj : constant.h, types.h, externs.h, config.h Xwizard.obj : constant.h, types.h, externs.h, config.h $ CALL UNPACK DESCRIP.MMS;1 1528972964 $ create 'f' X/* source/dungeon.c: the main command interpreter, updating player status X X Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke X X This software may be copied and distributed for educational, research, an Vd X not for profit purposes provided that this copyright and statement are X included in all such copies. */ X X#ifdef __TURBOC__ X#include`09 X#include`09 X#include`09 X#endif /* __TURBOC__ */ X`20 X#include "config.h" X#include "constant.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#ifndef ATARIST_MWC X#include X#endif X#else X#include X#endif X X#if defined(LINT_ARGS) Xstatic char original_commands(char); Xstatic void do_command(char); Xstatic int valid_countcommand(char); Xstatic void regenhp(int); Xstatic void regenmana(int); Xstatic int enchanted(inven_type *); Xstatic void examine_book(void); Xstatic void go_up(void); Xstatic void go_down(void); Xstatic void jamdoor(void); Xstatic void refill_lamp(void); X#else Xstatic char original_commands(); Xstatic void do_command(); Xstatic int valid_countcommand(); Xstatic void regenhp(); Xstatic void regenmana(); Xstatic int enchanted(); Xstatic void examine_book(); Xstatic void go_up(); Xstatic void go_down(); Xstatic void jamdoor(); Xstatic void refill_lamp(); X#endif X X#ifdef ATARIST_TC X/* Include this to get prototypes for standard library functions. */ X#include X#endif X X/* Moria game module`09`09`09`09`09-RAK-`09*/ X/* The code in this section has gone through many revisions, and */ X/* some of it could stand some more hard work.`09-RAK-`09 */ X X/* It has had a bit more hard work.`09`09`09-CJS- */ X Xvoid dungeon() X`7B X int find_count, i; X int regen_amount;`09 /* Regenerate hp and mana*/ X char command;`09`09/* Last command`09`09 */ X register struct misc *p_ptr; X register inven_type *i_ptr; X register struct flags *f_ptr; X#ifdef ATARIST_WMC X int32u holder; X#endif X X /* Main procedure for dungeon.`09`09`09-RAK-`09*/ X /* Note: There is a lot of preliminary magic going on here at first*/ X X /* init pointers. */ X f_ptr = &py.flags; X p_ptr = &py.misc; X X /* Check light status for setup`09 */ X i_ptr = &inventory`5BINVEN_LIGHT`5D; X if (i_ptr->p1 > 0) X player_light = TRUE; X else X player_light = FALSE; X /* Check for a maximum level`09`09 */ X if (dun_level > p_ptr->max_dlv) X p_ptr->max_dlv = dun_level; X X /* Reset flags and initialize variables */ X command_count = 0; X find_count = 0; X new_level_flag = FALSE; X find_flag`09= FALSE; X teleport_flag = FALSE; X mon_tot_mult`09= 0; X cave`5Bchar_row`5D`5Bchar_col`5D.cptr = 1; X /* Ensure we display the panel. Used to do this with a global var. -CJS- * V/ X panel_row = panel_col = -1; X /* Light up the area around character`09 */ X check_view (); X /* must do this after panel_row/col set to -1, because search_off() will X call check_view(), and so the panel_* variables must be valid before X search_off() is called */ X if (py.flags.status & PY_SEARCH) X search_off(); X /* Light, but do not move critters`09 */ X creatures(FALSE); X /* Print the depth`09`09`09 */ X prt_depth(); X#if 0 X /* This can't be right. */ X#ifdef ATARIST_MWC X prt_map(); X#endif X#endif X X /* Loop until dead, or new level`09`09*/ X do X `7B X /* Increment turn counter`09`09`09*/ X turn++; X#ifndef MAC X /* The Mac ignores the game hours file`09`09*/ X /* Check for game hours`09`09`09 */ X if (((turn % 250) == 1) && !check_time()) X`09if (closing_flag > 4) X`09 `7B X`09 msg_print("The gates to Moria are now closed."); X`09 (void) strcpy (died_from, "(closing gate: saved)"); X`09 if (!save_char()) X`09 `7B X`09`09(void) strcpy (died_from, "a slammed gate"); X`09`09death = TRUE; X`09 `7D X`09 exit_game(); X`09 `7D X`09else X`09 `7B X`09 disturb (0, 0); X`09 closing_flag++; X`09 msg_print("The gates to Moria are closing."); X`09 msg_print("Please finish up or save your game."); X`09 `7D X#endif X X /* turn over the store contents every, say, 1000 turns */ X if ((dun_level != 0) && ((turn % 1000) == 0)) X`09store_maint(); X X /* Check for creature generation`09`09*/ X if (randint(MAX_MALLOC_CHANCE) == 1) X`09alloc_monster(1, MAX_SIGHT, FALSE); X /* Check light status`09`09`09 */ X i_ptr = &inventory`5BINVEN_LIGHT`5D; X if (player_light) X`09if (i_ptr->p1 > 0) X`09 `7B X`09 i_ptr->p1--; X`09 if (i_ptr->p1 == 0) X`09 `7B X`09`09player_light = FALSE; X`09`09msg_print("Your light has gone out!"); X`09`09disturb (0, 1); X`09`09/* unlight creatures */ X`09`09creatures(FALSE); X`09 `7D X`09 else if ((i_ptr->p1 < 40) && (randint(5) == 1) && X`09`09 (py.flags.blind < 1)) X`09 `7B X`09`09disturb (0, 0); X`09`09msg_print("Your light is growing faint."); X`09 `7D X`09 `7D X`09else X`09 `7B X`09 player_light = FALSE; X`09 disturb (0, 1); X`09 /* unlight creatures */ X`09 creatures(FALSE); X`09 `7D X else if (i_ptr->p1 > 0) X`09`7B X`09 i_ptr->p1--; X`09 player_light = TRUE; X`09 disturb (0, 1); X`09 /* light creatures */ X`09 creatures(FALSE); X`09`7D X X /* Update counters and messages`09`09`09*/ X /* Check food status`09 */ X regen_amount = PLAYER_REGEN_NORMAL; X if (f_ptr->food < PLAYER_FOOD_ALERT) X`09`7B X`09 if (f_ptr->food < PLAYER_FOOD_WEAK) X`09 `7B X`09 if (f_ptr->food < 0) X`09`09regen_amount = 0; X`09 else if (f_ptr->food < PLAYER_FOOD_FAINT) X`09`09regen_amount = PLAYER_REGEN_FAINT; X`09 else if (f_ptr->food < PLAYER_FOOD_WEAK) X`09`09regen_amount = PLAYER_REGEN_WEAK; X`09 if ((PY_WEAK & f_ptr->status) == 0) X`09`09`7B X`09`09 f_ptr->status `7C= PY_WEAK; X`09`09 msg_print("You are getting weak from hunger."); X`09`09 disturb (0, 0); X`09`09 prt_hunger(); X`09`09`7D X`09 if ((f_ptr->food < PLAYER_FOOD_FAINT) && (randint(8) == 1)) X`09`09`7B X`09`09 f_ptr->paralysis += randint(5); X`09`09 msg_print("You faint from the lack of food."); X`09`09 disturb (1, 0); X`09`09`7D X`09 `7D X`09 else if ((PY_HUNGRY & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_HUNGRY; X`09 msg_print("You are getting hungry."); X`09 disturb (0, 0); X`09 prt_hunger(); X`09 `7D X`09`7D X /* Food consumption`09*/ X /* Note: Speeded up characters really burn up the food! */ X if (f_ptr->speed < 0) X`09f_ptr->food -=`09f_ptr->speed*f_ptr->speed; X f_ptr->food -= f_ptr->food_digested; X if (f_ptr->food < 0) X`09`7B X`09 take_hit (-f_ptr->food/16, "starvation"); /* -CJS- */ X`09 disturb(1, 0); X`09`7D X /* Regenerate`09 */ X if (f_ptr->regenerate) regen_amount = regen_amount * 3 / 2; X if ((py.flags.status & PY_SEARCH) `7C`7C f_ptr->rest != 0) X`09regen_amount = regen_amount * 2; X if ((py.flags.poisoned < 1) && (p_ptr->chp < p_ptr->mhp)) X`09regenhp(regen_amount); X if (p_ptr->cmana < p_ptr->mana) X`09regenmana(regen_amount); X /* Blindness`09 */ X if (f_ptr->blind > 0) X`09`7B X`09 if ((PY_BLIND & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_BLIND; X`09 prt_map(); X`09 prt_blind(); X`09 disturb (0, 1); X`09 /* unlight creatures */ X`09 creatures (FALSE); X`09 `7D X`09 f_ptr->blind--; X`09 if (f_ptr->blind == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_BLIND); X#else X`09 f_ptr->status &= `7EPY_BLIND; X#endif X`09 prt_blind(); X`09 prt_map(); X`09 /* light creatures */ X`09 disturb (0, 1); X`09 creatures(FALSE); X`09 msg_print("The veil of darkness lifts."); X`09 `7D X`09`7D X /* Confusion`09 */ X if (f_ptr->confused > 0) X`09`7B X`09 if ((PY_CONFUSED & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_CONFUSED; X`09 prt_confused(); X`09 `7D X`09 f_ptr->confused--; X`09 if (f_ptr->confused == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_CONFUSED); X#else X`09 f_ptr->status &= `7EPY_CONFUSED; X#endif X`09 prt_confused(); X`09 msg_print("You feel less confused now."); X`09 if (py.flags.rest != 0) X`09`09rest_off (); X`09 `7D X`09`7D X /* Afraid`09`09 */ X if (f_ptr->afraid > 0) X`09`7B X`09 if ((PY_FEAR & f_ptr->status) == 0) X`09 `7B X`09 if ((f_ptr->shero+f_ptr->hero) > 0) X`09`09f_ptr->afraid = 0; X`09 else X`09`09`7B X`09`09 f_ptr->status `7C= PY_FEAR; X`09`09 prt_afraid(); X`09`09`7D X`09 `7D X`09 else if ((f_ptr->shero+f_ptr->hero) > 0) X`09 f_ptr->afraid = 1; X`09 f_ptr->afraid--; X`09 if (f_ptr->afraid == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_FEAR); X#else X`09 f_ptr->status &= `7EPY_FEAR; X#endif X`09 prt_afraid(); X`09 msg_print("You feel bolder now."); X`09 disturb (0, 0); X`09 `7D X`09`7D X /* Poisoned`09 */ X if (f_ptr->poisoned > 0) X`09`7B X`09 if ((PY_POISONED & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_POISONED; X`09 prt_poisoned(); X`09 `7D X`09 f_ptr->poisoned--; X`09 if (f_ptr->poisoned == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_POISONED); X#else X`09 f_ptr->status &= `7EPY_POISONED; X#endif X`09 prt_poisoned(); X`09 msg_print("You feel better."); X`09 disturb (0, 0); X`09 `7D X`09 else X`09 `7B X`09 switch(con_adj()) X`09`09`7B X`09`09case -4: i = 4; break; X`09`09case -3: X`09`09case -2: i = 3; break; X`09`09case -1: i = 2; break; X`09`09case 0:`09 i = 1; break; X`09`09case 1: case 2: case 3: X`09`09 i = ((turn % 2) == 0); X`09`09 break; X`09`09case 4: case 5: X`09`09 i = ((turn % 3) == 0); X`09`09 break; X`09`09case 6: X`09`09 i = ((turn % 4) == 0); X`09`09 break; X`09`09`7D X`09 take_hit (i, "poison"); X`09 disturb (1, 0); X`09 `7D X`09`7D X /* Fast`09`09 */ X if (f_ptr->fast > 0) X`09`7B X`09 if ((PY_FAST & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_FAST; X`09 change_speed(-1); X`09 msg_print("You feel yourself moving faster."); X`09 disturb (0, 0); X`09 `7D X`09 f_ptr->fast--; X`09 if (f_ptr->fast == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_FAST); X#else X`09 f_ptr->status &= `7EPY_FAST; X#endif X`09 change_speed(1); X`09 msg_print("You feel yourself slow down."); X`09 disturb (0, 0); X`09 `7D X`09`7D X /* Slow`09`09 */ X if (f_ptr->slow > 0) X`09`7B X`09 if ((PY_SLOW & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_SLOW; X`09 change_speed(1); X`09 msg_print("You feel yourself moving slower."); X`09 disturb (0, 0); X`09 `7D X`09 f_ptr->slow--; X`09 if (f_ptr->slow == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_SLOW); X#else X`09 f_ptr->status &= `7EPY_SLOW; X#endif X`09 change_speed(-1); X`09 msg_print("You feel yourself speed up."); X`09 disturb (0, 0); X`09 `7D X`09`7D X /* Resting is over? */ X if (f_ptr->rest > 0) X`09`7B X`09 f_ptr->rest--; X`09 if (f_ptr->rest == 0)`09`09 /* Resting over`09 */ X`09 rest_off(); X`09`7D X else if (f_ptr->rest < 0) X`09`7B X`09 /* Rest until reach max mana and max hit points. */ X`09 f_ptr->rest++; X`09 if ((p_ptr->chp == p_ptr->mhp && p_ptr->cmana == p_ptr->mana) X`09 `7C`7C f_ptr->rest == 0) X`09 rest_off(); X`09`7D X X /* Check for interrupts to find or rest. */ X#ifdef MAC X /* On Mac, checking for input is expensive, since it involves handling X`09 events, so we only check in multiples of 16 turns. */ X if (!(turn & 0xF) && ((command_count > 0) `7C`7C find_flag X`09`09`09 `7C`7C (f_ptr->rest != 0))) X`09if (macgetkey(CNIL, TRUE)) X`09 disturb(0, 0); X#else X if ((command_count > 0 `7C`7C find_flag `7C`7C f_ptr->rest != 0) X#if defined(MSDOS) `7C`7C defined(VMS) X`09 && kbhit() X#else X`09 && (check_input (find_flag ? 0 : 10000)) X#endif X`09 ) X`09`7B X#ifdef MSDOS X`09 (void) msdos_getch(); X#endif X#ifdef VMS X`09 /* Get and ignore the key used to interrupt resting/running. */ X`09 (void) vms_getch (); X#endif X`09 disturb (0, 0); X`09`7D X#endif X X /* Hallucinating?`09 (Random characters appear!)*/ X if (f_ptr->image > 0) X`09`7B X`09 end_find (); X`09 f_ptr->image--; X`09 if (f_ptr->image == 0) X`09 prt_map ();`09 /* Used to draw entire screen! -CJS- */ X`09`7D X /* Paralysis`09 */ X if (f_ptr->paralysis > 0) X`09`7B X`09 /* when paralysis true, you can not see any movement that occurs */ X`09 f_ptr->paralysis--; X`09 disturb (1, 0); X`09`7D X /* Protection from evil counter*/ X if (f_ptr->protevil > 0) X`09`7B X`09 f_ptr->protevil--; X`09 if (f_ptr->protevil == 0) X`09 msg_print ("You no longer feel safe from evil."); X`09`7D X /* Invulnerability`09*/ X if (f_ptr->invuln > 0) X`09`7B X`09 if ((PY_INVULN & f_ptr->status) == 0) X`09 `7B X`09 f_ptr->status `7C= PY_INVULN; X`09 disturb (0, 0); X`09 py.misc.pac += 100; X`09 py.misc.dis_ac += 100; X`09 prt_pac(); X`09 msg_print("Your skin turns into steel!"); X`09 `7D X`09 f_ptr->invuln--; X`09 if (f_ptr->invuln == 0) X`09 `7B X#ifdef ATARIST_MWC X`09 f_ptr->status &= `7E(holder = PY_INVULN); X#else X`09 f_ptr->status &= `7EPY_INVULN; X#endif X`09 disturb (0, 0); X`09 py.misc.pac -= 100; X`09 py.misc.dis_ac -= 100; X`09 prt_pac(); +-+-+-+-+-+-+-+- END OF PART 12 +-+-+-+-+-+-+-+-