-+-+-+-+-+-+-+-+ START OF PART 48 -+-+-+-+-+-+-+-+ X#ifdef ATARIST_MWC X int32u holder; X#endif X X y = char_row; X x = char_col; X if (get_dir(CNIL, &dir)) X `7B X (void) mmove(dir, &y, &x); X c_ptr = &cave`5By`5D`5Bx`5D; X no_object = FALSE; X if (c_ptr->cptr > 1 && c_ptr->tptr != 0 && X`09 (t_list`5Bc_ptr->tptr`5D.tval == TV_CLOSED_DOOR X`09 `7C`7C t_list`5Bc_ptr->tptr`5D.tval == TV_CHEST)) X`09`7B X`09 m_ptr = &m_list`5Bc_ptr->cptr`5D; X`09 if (m_ptr->ml) X`09 (void) sprintf (m_name, "The %s", c_list`5Bm_ptr->mptr`5D.name); X`09 else X`09 (void) strcpy (m_name, "Something"); X`09 (void) sprintf(out_val, "%s is in your way!", m_name); X`09 msg_print(out_val); X`09`7D X else if (c_ptr->tptr != 0) X`09/* Closed door`09`09 */ X`09if (t_list`5Bc_ptr->tptr`5D.tval == TV_CLOSED_DOOR) X`09 `7B X`09 t_ptr = &t_list`5Bc_ptr->tptr`5D; X`09 if (t_ptr->p1 > 0)`09 /* It's locked.`09*/ X`09 `7B X`09`09p_ptr = &py.misc; X`09`09i = p_ptr->disarm + 2*todis_adj() + stat_adj(A_INT) X`09`09 + (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_DISARM`5D X`09`09 * p_ptr->lev / 3); X`09`09if (py.flags.confused > 0) X`09`09 msg_print("You are too confused to pick the lock."); X`09`09else if ((i-t_ptr->p1) > randint(100)) X`09`09 `7B X`09`09 msg_print("You have picked the lock."); X`09`09 py.misc.exp++; X`09`09 prt_experience(); X`09`09 t_ptr->p1 = 0; X`09`09 `7D X`09`09else X`09`09 count_msg_print("You failed to pick the lock."); X`09 `7D X`09 else if (t_ptr->p1 < 0)`09 /* It's stuck`09 */ X`09 msg_print("It appears to be stuck."); X`09 if (t_ptr->p1 == 0) X`09 `7B X`09`09invcopy(&t_list`5Bc_ptr->tptr`5D, OBJ_OPEN_DOOR); X`09`09c_ptr->fval = CORR_FLOOR; X`09`09lite_spot(y, x); X`09`09command_count = 0; X`09 `7D X`09 `7D X /* Open a closed chest.`09`09 */ X`09else if (t_list`5Bc_ptr->tptr`5D.tval == TV_CHEST) X`09 `7B X`09 p_ptr = &py.misc; X`09 i = p_ptr->disarm + 2*todis_adj() + stat_adj(A_INT) X`09 + (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_DISARM`5D * p_ptr->lev V / 3); X`09 t_ptr = &t_list`5Bc_ptr->tptr`5D; X`09 flag = FALSE; X`09 if (CH_LOCKED & t_ptr->flags) X`09 if (py.flags.confused > 0) X`09`09msg_print("You are too confused to pick the lock."); X`09 else if ((i-(int)t_ptr->level) > randint(100)) X`09`09`7B X`09`09 msg_print("You have picked the lock."); X`09`09 flag = TRUE; X`09`09 py.misc.exp += t_ptr->level; X`09`09 prt_experience(); X`09`09`7D X`09 else X`09`09count_msg_print("You failed to pick the lock."); X`09 else X`09 flag = TRUE; X`09 if (flag) X`09 `7B X`09`09t_ptr->flags &= `7ECH_LOCKED; X`09`09t_ptr->name2 = SN_EMPTY; X`09`09known2(t_ptr); X`09`09t_ptr->cost = 0; X`09 `7D X`09 flag = FALSE; X`09 /* Was chest still trapped?`09 (Snicker) */ X`09 if ((CH_LOCKED & t_ptr->flags) == 0) X`09 `7B X`09`09chest_trap(y, x); X`09`09if (c_ptr->tptr != 0) X`09`09 flag = TRUE; X`09 `7D X`09 /* Chest treasure is allocated as if a creature */ X`09 /* had been killed.`09`09`09`09 */ X`09 if (flag) X`09 `7B X`09`09/* clear the cursed chest/monster win flag, so that people X`09`09 can not win by opening a cursed chest */ X#ifdef ATARIST_MWC X`09`09t_list`5Bc_ptr->tptr`5D.flags &= `7E(holder = TR_CURSED); X#else X`09`09t_list`5Bc_ptr->tptr`5D.flags &= `7ETR_CURSED; X#endif X`09`09(void) monster_death(y, x, t_list`5Bc_ptr->tptr`5D.flags); X`09`09t_list`5Bc_ptr->tptr`5D.flags = 0; X`09 `7D X`09 `7D X`09else X`09 no_object = TRUE; X else X`09no_object = TRUE; X X if (no_object) X`09`7B X`09 msg_print("I do not see anything you can open there."); X`09 free_turn_flag = TRUE; X`09`7D X `7D X`7D X X X/* Closes an open door.`09`09`09`09-RAK-`09*/ Xvoid closeobject() X`7B X int y, x, dir, no_object; X vtype out_val, m_name; X register cave_type *c_ptr; X register monster_type *m_ptr; X X y = char_row; X x = char_col; X if (get_dir(CNIL, &dir)) X `7B X (void) mmove(dir, &y, &x); X c_ptr = &cave`5By`5D`5Bx`5D; X no_object = FALSE; X if (c_ptr->tptr != 0) X`09if (t_list`5Bc_ptr->tptr`5D.tval == TV_OPEN_DOOR) X`09 if (c_ptr->cptr == 0) X`09 if (t_list`5Bc_ptr->tptr`5D.p1 == 0) X`09 `7B X`09`09invcopy(&t_list`5Bc_ptr->tptr`5D, OBJ_CLOSED_DOOR); X`09`09c_ptr->fval = BLOCKED_FLOOR; X`09`09lite_spot(y, x); X`09 `7D X`09 else X`09 msg_print("The door appears to be broken."); X`09 else X`09 `7B X`09 m_ptr = &m_list`5Bc_ptr->cptr`5D; X`09 if (m_ptr->ml) X`09`09(void) sprintf (m_name, "The %s", c_list`5Bm_ptr->mptr`5D.name); X`09 else X`09`09(void) strcpy (m_name, "Something"); X`09 (void) sprintf(out_val, "%s is in your way!", m_name); X`09 msg_print(out_val); X`09 `7D X`09else X`09 no_object = TRUE; X else X`09no_object = TRUE; X X if (no_object) X`09`7B X`09 msg_print("I do not see anything you can close there."); X`09 free_turn_flag = TRUE; X`09`7D X `7D X`7D X X X/* Tunneling through real wall: 10, 11, 12`09`09-RAK-`09*/ X/* Used by TUNNEL and WALL_TO_MUD`09`09`09`09 */ Xint twall(y, x, t1, t2) Xint y, x, t1, t2; X`7B X register int i, j; X register cave_type *c_ptr; X int res, found; X X res = FALSE; X if (t1 > t2) X `7B X c_ptr = &cave`5By`5D`5Bx`5D; X if (c_ptr->lr) X`09`7B X`09 /* should become a room space, check to see whether it should be X`09 LIGHT_FLOOR or DARK_FLOOR */ X`09 found = FALSE; X`09 for (i = y-1; i <= y+1; i++) X`09 for (j = x-1; j <= x+1; j++) X`09 if (cave`5Bi`5D`5Bj`5D.fval <= MAX_CAVE_ROOM) X`09`09`7B X`09`09 c_ptr->fval = cave`5Bi`5D`5Bj`5D.fval; X`09`09 c_ptr->pl = cave`5Bi`5D`5Bj`5D.pl; X`09`09 found = TRUE; X`09`09 break; X`09`09`7D X`09 if (!found) X`09 `7B X`09 c_ptr->fval = CORR_FLOOR; X`09 c_ptr->pl = FALSE; X`09 `7D X`09`7D X else X`09`7B X`09 /* should become a corridor space */ X`09 c_ptr->fval = CORR_FLOOR; X`09 c_ptr->pl = FALSE; X`09`7D X c_ptr->fm = FALSE; X if (panel_contains(y, x)) X`09if ((c_ptr->tl `7C`7C c_ptr->pl) && c_ptr->tptr != 0) X`09 msg_print("You have found something!"); X lite_spot(y, x); X res = TRUE; X `7D X return(res); X`7D $ CALL UNPACK MORIA3.C;1 2137819215 $ create 'f' X/* source/moria4.c: misc code, mainly to handle player commands 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#endif X 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#include X X X#if defined(LINT_ARGS) Xstatic int look_ray(int, int, int); Xstatic int look_see(int, int, int *); Xstatic void inven_throw(int, struct inven_type *); Xstatic void facts(struct inven_type *, int *, int *, int *, int *); Xstatic void drop_throw(int, int, struct inven_type *); Xstatic void py_bash(int, int); X#else Xstatic int look_ray(); Xstatic int look_see(); X#endif X X X/* Tunnels through rubble and walls`09`09`09-RAK-`09*/ X/* Must take into account: secret doors, special tools`09`09 */ Xvoid tunnel(dir) Xint dir; X`7B X register int i, tabil; X register cave_type *c_ptr; X register inven_type *i_ptr; X int y, x; X monster_type *m_ptr; X vtype out_val, m_name; X#ifdef ATARIST_MWC X int32u holder; X#endif X X if ((py.flags.confused > 0) && /* Confused?`09 */ X (randint(4) > 1))`09`09 /* 75% random movement */ X dir = randint(9); X y = char_row; X x = char_col; X (void) mmove(dir, &y, &x); X X c_ptr = &cave`5By`5D`5Bx`5D; X /* Compute the digging ability of player; based on`09 */ X /* strength, and type of tool used`09`09`09 */ X tabil = py.stats.use_stat`5BA_STR`5D; X i_ptr = &inventory`5BINVEN_WIELD`5D; X X /* Don't let the player tunnel somewhere illegal, this is necessary to X prevent the player from getting a free attack by trying to tunnel X somewhere where it has no effect. */ X if (c_ptr->fval < MIN_CAVE_WALL X && (c_ptr->tptr == 0 `7C`7C (t_list`5Bc_ptr->tptr`5D.tval != TV_RUBBLE X`09`09`09 && t_list`5Bc_ptr->tptr`5D.tval != TV_SECRET_DOOR))) X `7B X if (c_ptr->tptr == 0) X`09`7B X`09 msg_print ("Tunnel through what? Empty air?!?"); X`09 free_turn_flag = TRUE; X`09`7D X else X`09`7B X`09 msg_print("You can't tunnel through that."); X`09 free_turn_flag = TRUE; X`09`7D X return; X `7D X X if (c_ptr->cptr > 1) X `7B X m_ptr = &m_list`5Bc_ptr->cptr`5D; X if (m_ptr->ml) X`09(void) sprintf (m_name, "The %s", c_list`5Bm_ptr->mptr`5D.name); X else X`09(void) strcpy (m_name, "Something"); X (void) sprintf(out_val, "%s is in your way!", m_name); X msg_print(out_val); X X /* let the player attack the creature */ X if (py.flags.afraid < 1) X`09py_attack(y, x); X else X`09msg_print("You are too afraid!"); X `7D X else if (i_ptr->tval != TV_NOTHING) X `7B X#ifdef ATARIST_MWC X if ((holder = TR_TUNNEL) & i_ptr->flags) X#else X if (TR_TUNNEL & i_ptr->flags) X#endif X`09tabil += 25 + i_ptr->p1*50; X else X`09`7B X`09 tabil += (i_ptr->damage`5B0`5D*i_ptr->damage`5B1`5D) + i_ptr->tohit X`09 + i_ptr->todam; X`09 /* divide by two so that digging without shovel isn't too easy */ X`09 tabil >>= 1; X`09`7D X X /* If this weapon is too heavy for the player to wield properly, then X`09 also make it harder to dig with it. */ X X if (weapon_heavy) X`09`7B X`09 tabil += (py.stats.use_stat`5BA_STR`5D * 15) - i_ptr->weight; X`09 if (tabil < 0) X`09 tabil = 0; X`09`7D X X /* Regular walls; Granite, magma intrusion, quartz vein */ X /* Don't forget the boundary walls, made of titanium (255)*/ X switch(c_ptr->fval) X`09`7B X`09case GRANITE_WALL: X`09 i = randint(1200) + 80; X`09 if (twall(y, x, tabil, i)) X`09 msg_print("You have finished the tunnel."); X`09 else X`09 count_msg_print("You tunnel into the granite wall."); X`09 break; X`09case MAGMA_WALL: X`09 i = randint(600) + 10; X`09 if (twall(y, x, tabil, i)) X`09 msg_print("You have finished the tunnel."); X`09 else X`09 count_msg_print("You tunnel into the magma intrusion."); X`09 break; X`09case QUARTZ_WALL: X`09 i = randint(400) + 10; X`09 if (twall(y, x, tabil, i)) X`09 msg_print("You have finished the tunnel."); X`09 else X`09 count_msg_print("You tunnel into the quartz vein."); X`09 break; X`09case BOUNDARY_WALL: X`09 msg_print("This seems to be permanent rock."); X`09 break; X`09default: X`09 /* Is there an object in the way? (Rubble and secret doors)*/ X`09 if (c_ptr->tptr != 0) X`09 `7B X`09 /* Rubble. */ X`09 if (t_list`5Bc_ptr->tptr`5D.tval == TV_RUBBLE) X`09`09`7B X`09`09 if (tabil > randint(180)) X`09`09 `7B X`09`09 (void) delete_object(y, x); X`09`09 msg_print("You have removed the rubble."); X`09`09 if (randint(10) == 1) X`09`09`09`7B X`09`09`09 place_object(y, x); X`09`09`09 if (test_light(y, x)) X`09`09`09 msg_print("You have found something!"); X`09`09`09`7D X`09`09 lite_spot(y, x); X`09`09 `7D X`09`09 else X`09`09 count_msg_print("You dig in the rubble."); X`09`09`7D X`09 /* Secret doors.*/ X`09 else if (t_list`5Bc_ptr->tptr`5D.tval == TV_SECRET_DOOR) X`09`09`7B X`09`09 count_msg_print("You tunnel into the granite wall."); X`09`09 search(char_row, char_col, py.misc.srh); X`09`09`7D X`09 else X`09`09abort (); X`09 `7D X`09 else X`09 abort (); X`09 break; X`09`7D X `7D X else X msg_print("You dig with your hands, making no progress."); X`7D X X X/* Disarms a trap`09`09`09`09`09-RAK-`09*/ Xvoid disarm_trap() X`7B X int y, x, level, tmp, dir, no_disarm; X register int tot, i; X register cave_type *c_ptr; X register inven_type *i_ptr; X monster_type *m_ptr; X vtype m_name, out_val; X X y = char_row; X x = char_col; X if (get_dir(CNIL, &dir)) X `7B X (void) mmove(dir, &y, &x); X c_ptr = &cave`5By`5D`5Bx`5D; X no_disarm = FALSE; X if (c_ptr->cptr > 1 && c_ptr->tptr != 0 && X`09 (t_list`5Bc_ptr->tptr`5D.tval == TV_VIS_TRAP X`09 `7C`7C t_list`5Bc_ptr->tptr`5D.tval == TV_CHEST)) X`09`7B X`09 m_ptr = &m_list`5Bc_ptr->cptr`5D; X`09 if (m_ptr->ml) X`09 (void) sprintf (m_name, "The %s", c_list`5Bm_ptr->mptr`5D.name); X`09 else X`09 (void) strcpy (m_name, "Something"); X`09 (void) sprintf(out_val, "%s is in your way!", m_name); X`09 msg_print(out_val); X`09`7D X else if (c_ptr->tptr != 0) X`09`7B X`09 tot = py.misc.disarm + 2*todis_adj() + stat_adj(A_INT) X`09 + (class_level_adj`5Bpy.misc.pclass`5D`5BCLA_DISARM`5D * py.misc.lev V / 3); X`09 if ((py.flags.blind > 0) `7C`7C (no_light())) X`09 tot = tot / 10; X`09 if (py.flags.confused > 0) X`09 tot = tot / 10; X`09 if (py.flags.image > 0) X`09 tot = tot / 10; X`09 i_ptr = &t_list`5Bc_ptr->tptr`5D; X`09 i = i_ptr->tval; X`09 level = i_ptr->level; X`09 if (i == TV_VIS_TRAP)`09`09 /* Floor trap */ X`09 `7B X`09 if ((tot + 100 - level) > randint(100)) X`09`09`7B X`09`09 msg_print("You have disarmed the trap."); X`09`09 py.misc.exp += i_ptr->p1; X`09`09 (void) delete_object(y, x); X`09`09 /* make sure we move onto the trap even if confused */ X`09`09 tmp = py.flags.confused; X`09`09 py.flags.confused = 0; X`09`09 move_char(dir, FALSE); X`09`09 py.flags.confused = tmp; X`09`09 prt_experience(); X`09`09`7D X`09 /* avoid randint(0) call */ X`09 else if ((tot > 5) && (randint(tot) > 5)) X`09`09count_msg_print("You failed to disarm the trap."); X`09 else X`09`09`7B X`09`09 msg_print("You set the trap off!"); X`09`09 /* make sure we move onto the trap even if confused */ X`09`09 tmp = py.flags.confused; X`09`09 py.flags.confused = 0; X`09`09 move_char(dir, FALSE); X`09`09 py.flags.confused += tmp; X`09`09`7D X`09 `7D X`09 else if (i == TV_CHEST) X`09 `7B +-+-+-+-+-+-+-+- END OF PART 48 +-+-+-+-+-+-+-+-