-+-+-+-+-+-+-+-+ START OF PART 47 -+-+-+-+-+-+-+-+ X number += damroll(4, 2); X if (number > 0) X dump = summon_object(y, x, number, i); X else X dump = 0; X#else X holder = CM_CARRY_OBJ; X if (flags & holder) X i = 1; X else X i = 0; X holder = CM_CARRY_GOLD; X if (flags & holder) X i += 2; X X number = 0; X holder = CM_60_RANDOM; X if ((flags & holder) && (randint(100) < 60)) X number++; X holder = CM_90_RANDOM; X if ((flags & holder) && (randint(100) < 90)) X number++; X holder = CM_1D2_OBJ; X if (flags & holder) X number += randint(2); X holder = CM_2D2_OBJ; X if (flags & holder) X number += damroll(2, 2); X holder = CM_4D2_OBJ; X if (flags & holder) X number += damroll(4, 2); X if (number > 0) X dump = summon_object(y, x, number, i); X else X dump = 0; X X X#endif X X#if defined(ATARIST_MWC) X holder = CM_WIN; X if (flags & holder) X#else X if (flags & CM_WIN) X#endif X `7B X total_winner = TRUE; X prt_winner(); X msg_print("*** CONGRATULATIONS *** You have won the game."); X msg_print("You cannot save this game, but you may retire when ready.") V; X `7D X X if (dump) X `7B X res = 0; X if (dump & 255) X#ifdef ATARIST_MWC X`09`7B X`09 holder = CM_CARRY_OBJ; X`09 res `7C= holder; X`09`7D X#else X res `7C= CM_CARRY_OBJ; X#endif X if (dump >= 256) X#ifdef ATARIST_MWC X`09`7B X`09 holder = CM_CARRY_GOLD; X`09 res `7C= holder; X`09`7D X#else X`09res `7C= CM_CARRY_GOLD; X#endif X dump = (dump % 256) + (dump / 256); /* number of items */ X res `7C= dump << CM_TR_SHIFT; X `7D X else X res = 0; X X return res; X`7D X X X/* Decreases monsters hit points and deletes monster if needed.`09*/ X/* (Picking on my babies.)`09`09`09 -RAK- */ Xint mon_take_hit(monptr, dam) Xint monptr, dam; X`7B X register int32u i; X int32 new_exp, new_exp_frac; X register monster_type *m_ptr; X register struct misc *p_ptr; X register creature_type *c_ptr; X int m_take_hit; X int32u tmp; X#ifdef ATARIST_MWC X int32u holder; X#endif X X m_ptr = &m_list`5Bmonptr`5D; X m_ptr->hp -= dam; X m_ptr->csleep = 0; X if (m_ptr->hp < 0) X `7B X i = monster_death((int)m_ptr->fy, (int)m_ptr->fx, X`09`09`09c_list`5Bm_ptr->mptr`5D.cmove); X if ((py.flags.blind < 1 && m_ptr->ml) X#ifdef ATARIST_MWC X`09 `7C`7C (c_list`5Bm_ptr->mptr`5D.cmove & (holder = CM_WIN))) X#else X`09 `7C`7C (c_list`5Bm_ptr->mptr`5D.cmove & CM_WIN)) X#endif X`09`7B X#ifdef ATARIST_MWC X`09 holder = CM_TREASURE; X`09 tmp = (c_recall`5Bm_ptr->mptr`5D.r_cmove & holder) >> CM_TR_SHIFT; X`09 if (tmp > ((i & holder) >> CM_TR_SHIFT)) X`09 i = (i & `7Eholder) `7C (tmp << CM_TR_SHIFT); X`09 c_recall`5Bm_ptr->mptr`5D.r_cmove = X`09 (c_recall`5Bm_ptr->mptr`5D.r_cmove & `7Eholder) `7C i; X#else X`09 tmp = (c_recall`5Bm_ptr->mptr`5D.r_cmove & CM_TREASURE) >> CM_TR_SHIFT; X`09 if (tmp > ((i & CM_TREASURE) >> CM_TR_SHIFT)) X`09 i = (i & `7ECM_TREASURE) `7C (tmp << CM_TR_SHIFT); X`09 c_recall`5Bm_ptr->mptr`5D.r_cmove = X`09 (c_recall`5Bm_ptr->mptr`5D.r_cmove & `7ECM_TREASURE) `7C i; X#endif X`09 if (c_recall`5Bm_ptr->mptr`5D.r_kills < MAX_SHORT) X`09 c_recall`5Bm_ptr->mptr`5D.r_kills++; X`09`7D X c_ptr = &c_list`5Bm_ptr->mptr`5D; X p_ptr = &py.misc; X X new_exp = ((long)c_ptr->mexp * c_ptr->level) / p_ptr->lev; X new_exp_frac = ((((long)c_ptr->mexp * c_ptr->level) % p_ptr->lev) X`09* 0x10000L / p_ptr->lev) + p_ptr->exp_frac; X if (new_exp_frac >= 0x10000L) X`09`7B X`09 new_exp++; X`09 p_ptr->exp_frac = new_exp_frac - 0x10000L; X`09`7D X else X`09p_ptr->exp_frac = new_exp_frac; X X p_ptr->exp += new_exp; X /* can't call prt_experience() here, as that would result in "new leve Vl" X`09 message appearing before "monster dies" message */ X m_take_hit = m_ptr->mptr; X /* in case this is called from within creatures(), this is a X`09 horrible hack, the m_list/creatures() code needs to be X`09 rewritten */ X if (hack_monptr < monptr) X`09delete_monster(monptr); X else X`09fix1_delete_monster(monptr); X `7D X else X m_take_hit = -1; X return(m_take_hit); X`7D X X X/* Player attacks a (poor, defenseless) creature`09-RAK-`09*/ Xvoid py_attack(y, x) Xint y, x; X`7B X register int k, blows; X int crptr, monptr, tot_tohit, base_tohit; X vtype m_name, out_val; X register inven_type *i_ptr; X register struct misc *p_ptr; X#ifdef ATARIST_MWC X int32u holder; X#endif X X crptr = cave`5By`5D`5Bx`5D.cptr; X monptr = m_list`5Bcrptr`5D.mptr; X m_list`5Bcrptr`5D.csleep = 0; X i_ptr = &inventory`5BINVEN_WIELD`5D; X /* Does the player know what he's fighting?`09 */ X if (!m_list`5Bcrptr`5D.ml) X (void) strcpy(m_name, "it"); X else X (void) sprintf(m_name, "the %s", c_list`5Bmonptr`5D.name); X if (i_ptr->tval != TV_NOTHING)`09`09/* Proper weapon */ X blows = attack_blows((int)i_ptr->weight, &tot_tohit); X else`09`09`09`09`09 /* Bare hands? */ X `7B X blows = 2; X tot_tohit = -3; X `7D X if ((i_ptr->tval >= TV_SLING_AMMO) && (i_ptr->tval <= TV_SPIKE)) X /* Fix for arrows */ X blows = 1; X p_ptr = &py.misc; X tot_tohit += p_ptr->ptohit; X /* if creature not lit, make it more difficult to hit */ X if (m_list`5Bcrptr`5D.ml) X base_tohit = p_ptr->bth; X else X base_tohit = (p_ptr->bth / 2) - (tot_tohit * (BTH_PLUS_ADJ-1)) X - (p_ptr->lev * class_level_adj`5Bp_ptr->pclass`5D`5BCLA_BTH`5D / 2); X X /* Loop for number of blows,`09trying to hit the critter.`09 */ X do X `7B X if (test_hit(base_tohit, (int)p_ptr->lev, tot_tohit, X`09`09 (int)c_list`5Bmonptr`5D.ac, CLA_BTH)) X`09`7B X`09 (void) sprintf(out_val, "You hit %s.", m_name); X`09 msg_print(out_val); X`09 if (i_ptr->tval != TV_NOTHING) X`09 `7B X`09 k = pdamroll(i_ptr->damage); X`09 k = tot_dam(i_ptr, k, monptr); X`09 k = critical_blow((int)i_ptr->weight, tot_tohit, k, CLA_BTH); X`09 `7D X`09 else`09`09`09 /* Bare hands!? */ X`09 `7B X`09 k = damroll(1, 1); X`09 k = critical_blow(1, 0, k, CLA_BTH); X`09 `7D X`09 k += p_ptr->ptodam; X`09 if (k < 0) k = 0; X X`09 if (py.flags.confuse_monster) X`09 `7B X`09 py.flags.confuse_monster = FALSE; X`09 msg_print("Your hands stop glowing."); X`09 if ((c_list`5Bmonptr`5D.cdefense & CD_NO_SLEEP) X`09`09 `7C`7C (randint(MAX_MONS_LEVEL) < c_list`5Bmonptr`5D.level)) X`09`09(void) sprintf(out_val, "%s is unaffected.", m_name); X`09 else X`09`09`7B X`09`09 (void) sprintf(out_val, "%s appears confused.", m_name); X`09`09 m_list`5Bcrptr`5D.confused = TRUE; X`09`09`7D X`09 msg_print(out_val); X`09 if (m_list`5Bcrptr`5D.ml && randint(4) == 1) X`09`09c_recall`5Bmonptr`5D.r_cdefense `7C= X`09`09 c_list`5Bmonptr`5D.cdefense & CD_NO_SLEEP; X`09 `7D X X`09 /* See if we done it in.`09`09`09`09 */ X`09 if (mon_take_hit(crptr, k) >= 0) X`09 `7B X`09 (void) sprintf(out_val, "You have slain %s.", m_name); X`09 msg_print(out_val); X`09 prt_experience(); X`09 blows = 0; X`09 `7D X X`09 if ((i_ptr->tval >= TV_SLING_AMMO) X`09 && (i_ptr->tval <= TV_SPIKE)) /* Use missiles up*/ X`09 `7B X`09 i_ptr->number--; X`09 inven_weight -= i_ptr->weight; X#ifdef ATARIST_MWC X`09 py.flags.status `7C= (holder = PY_STR_WGT); X#else X`09 py.flags.status `7C= PY_STR_WGT; X#endif X`09 if (i_ptr->number == 0) X`09`09`7B X`09`09 equip_ctr--; X`09`09 py_bonuses(i_ptr, -1); X`09`09 invcopy(i_ptr, OBJ_NOTHING); X`09`09 calc_bonuses(); X`09`09`7D X`09 `7D X`09`7D X else X`09`7B X`09 (void) sprintf(out_val, "You miss %s.", m_name); X`09 msg_print(out_val); X`09`7D X blows--; X `7D X while (blows >= 1); X`7D X X X/* Moves player from one space to another.`09`09-RAK-`09*/ X/* Note: This routine has been pre-declared; see that for argument*/ Xvoid move_char(dir, do_pickup) Xint dir, do_pickup; X`7B X int old_row, old_col, old_find_flag; X int y, x; X register int i, j; X register cave_type *c_ptr, *d_ptr; X X if ((py.flags.confused > 0) && /* Confused?`09 */ X (randint(4) > 1) &&`09 /* 75% random movement */ X (dir != 5))`09`09 /* Never random if sitting*/ X `7B X dir = randint(9); X end_find(); X `7D X y = char_row; X x = char_col; X if (mmove(dir, &y, &x)) /* Legal move?`09 */ X `7B X c_ptr = &cave`5By`5D`5Bx`5D; X /* if there is no creature, or an unlit creature in the walls then... V */ X /* disallow attacks against unlit creatures in walls because moving in Vto X`09 a wall is a free turn normally, hence don't give player free turns X`09 attacking each wall in an attempt to locate the invisible creature, X`09 instead force player to tunnel into walls which always takes a turn */ X if ((c_ptr->cptr < 2) X`09 `7C`7C (!m_list`5Bc_ptr->cptr`5D.ml && c_ptr->fval >= MIN_CLOSED_SPACE) V) X`09`7B X`09 if (c_ptr->fval <= MAX_OPEN_SPACE) /* Open floor spot`09*/ X`09 `7B X`09 /* Make final assignments of char co-ords */ X`09 old_row = char_row; X`09 old_col = char_col; X`09 char_row = y; X`09 char_col = x; X`09 /* Move character record (-1)`09 */ X`09 move_rec(old_row, old_col, char_row, char_col); X`09 /* Check for new panel`09`09 */ X`09 if (get_panel(char_row, char_col, FALSE)) X`09`09prt_map(); X`09 /* Check to see if he should stop`09 */ X`09 if (find_flag) X`09`09area_affect(dir, char_row, char_col); X`09 /* Check to see if he notices something */ X`09 /* fos may be negative if have good rings of searching */ X`09 if ((py.misc.fos <= 1) `7C`7C (randint(py.misc.fos) == 1) `7C`7C X`09`09 (py.flags.status & PY_SEARCH)) X`09`09search(char_row, char_col, py.misc.srh); X`09 /* A room of light should be lit.`09 */ X`09 if (c_ptr->fval == LIGHT_FLOOR) X`09`09`7B X`09`09 if (!c_ptr->pl && !py.flags.blind) X`09`09 light_room(char_row, char_col); X`09`09`7D X`09 /* In doorway of light-room?`09 */ X`09 else if (c_ptr->lr && (py.flags.blind < 1)) X`09`09for (i = (char_row - 1); i <= (char_row + 1); i++) X`09`09 for (j = (char_col - 1); j <= (char_col + 1); j++) X`09`09 `7B X`09`09 d_ptr = &cave`5Bi`5D`5Bj`5D; X`09`09 if ((d_ptr->fval == LIGHT_FLOOR) && (!d_ptr->pl)) X`09`09`09light_room(i, j); X`09`09 `7D X`09 /* Move the light source`09`09 */ X`09 move_light(old_row, old_col, char_row, char_col); X`09 /* An object is beneath him.`09 */ X`09 if (c_ptr->tptr != 0) X`09`09`7B X`09`09 carry(char_row, char_col, do_pickup); X`09`09 /* if stepped on falling rock trap, and space contains X`09`09 rubble, then step back into a clear area */ X`09`09 if (t_list`5Bc_ptr->tptr`5D.tval == TV_RUBBLE) X`09`09 `7B X`09`09 move_rec(char_row, char_col, old_row, old_col); X`09`09 move_light(char_row, char_col, old_row, old_col); X`09`09 char_row = old_row; X`09`09 char_col = old_col; X`09`09 /* check to see if we have stepped back onto another X`09`09`09 trap, if so, set it off */ X`09`09 c_ptr = &cave`5Bchar_row`5D`5Bchar_col`5D; X`09`09 if (c_ptr->tptr != 0) X`09`09`09`7B X`09`09`09 i = t_list`5Bc_ptr->tptr`5D.tval; X`09`09`09 if (i == TV_INVIS_TRAP `7C`7C i == TV_VIS_TRAP X`09`09`09 `7C`7C i == TV_STORE_DOOR) X`09`09`09 hit_trap(char_row, char_col); X`09`09`09`7D X`09`09 `7D X`09`09`7D X`09 `7D X`09 else`09 /*Can't move onto floor space*/ X`09 `7B X`09 if (!find_flag && (c_ptr->tptr != 0)) X`09`09`7B X`09`09 if (t_list`5Bc_ptr->tptr`5D.tval == TV_RUBBLE) X`09`09 msg_print("There is rubble blocking your way."); X`09`09 else if (t_list`5Bc_ptr->tptr`5D.tval == TV_CLOSED_DOOR) X`09`09 msg_print("There is a closed door blocking your way."); X`09`09`7D X`09 else X`09`09end_find(); X`09 free_turn_flag = TRUE; X`09 `7D X`09`7D X else`09 /* Attacking a creature! */ X`09`7B X`09 old_find_flag = find_flag; X`09 end_find(); X`09 /* if player can see monster, and was in find mode, then nothing */ X`09 if (m_list`5Bc_ptr->cptr`5D.ml && old_find_flag) X`09 `7B X`09 /* did not do anything this turn */ X`09 free_turn_flag = TRUE; X`09 `7D X`09 else X`09 `7B X`09 if (py.flags.afraid < 1)`09`09/* Coward?`09*/ X`09`09py_attack(y, x); X`09 else`09`09`09`09/* Coward!`09*/ X`09`09msg_print("You are too afraid!"); X`09 `7D X`09`7D X `7D X`7D X X X/* Chests have traps too.`09`09`09`09-RAK-`09*/ X/* Note: Chest traps are based on the FLAGS value`09`09 */ Xvoid chest_trap(y, x) Xint y, x; X`7B X register int i; X int j, k; X register inven_type *t_ptr; X X t_ptr = &t_list`5Bcave`5By`5D`5Bx`5D.tptr`5D; X if (CH_LOSE_STR & t_ptr->flags) X `7B X msg_print("A small needle has pricked you!"); X if (!py.flags.sustain_str) X`09`7B X`09 (void) dec_stat(A_STR); X`09 take_hit(damroll(1, 4), "a poison needle"); X`09 msg_print("You feel weakened!"); X`09`7D X else X`09msg_print("You are unaffected."); X `7D X if (CH_POISON & t_ptr->flags) X `7B X msg_print("A small needle has pricked you!"); X take_hit(damroll(1, 6), "a poison needle"); X py.flags.poisoned += 10 + randint(20); X `7D X if (CH_PARALYSED & t_ptr->flags) X `7B X msg_print("A puff of yellow gas surrounds you!"); X if (py.flags.free_act) X`09msg_print("You are unaffected."); X else X`09`7B X`09 msg_print("You choke and pass out."); X`09 py.flags.paralysis = 10 + randint(20); X`09`7D X `7D X if (CH_SUMMON & t_ptr->flags) X `7B X for (i = 0; i < 3; i++) X`09`7B X`09 j = y; X`09 k = x; X`09 (void) summon_monster(&j, &k, FALSE); X`09`7D X `7D X if (CH_EXPLODE & t_ptr->flags) X `7B X msg_print("There is a sudden explosion!"); X (void) delete_object(y, x); X take_hit(damroll(5, 8), "an exploding chest"); X `7D X`7D X X X/* Opens a closed door or closed chest.`09`09-RAK-`09*/ Xvoid openobject() X`7B X int y, x, i, dir; X int flag, no_object; X register cave_type *c_ptr; X register inven_type *t_ptr; X register struct misc *p_ptr; X register monster_type *m_ptr; X vtype m_name, out_val; +-+-+-+-+-+-+-+- END OF PART 47 +-+-+-+-+-+-+-+-