-+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+ X`09 case 13:`09/*Steal Object`09 */ X`09 if ((py.flags.paralysis < 1) && X`09`09 (randint(124) < py.stats.use_stat`5BA_DEX`5D)) X`09`09msg_print("You grab hold of your backpack!"); X`09 else X`09`09`7B X`09`09 i = randint(inven_ctr) - 1; X`09`09 inven_destroy(i); X`09`09 msg_print("Your backpack feels lighter."); X`09`09`7D X`09 if (randint(2) == 1) X`09`09`7B X`09`09 msg_print("There is a puff of smoke!"); X`09`09 teleport_away(monptr, MAX_SIGHT); X`09`09`7D X`09 break; X`09 case 14:`09/*Poison`09 */ X`09 f_ptr = &py.flags; X`09 take_hit(damage, ddesc); X`09 msg_print("You feel very sick."); X`09 f_ptr->poisoned += randint((int)r_ptr->level)+5; X`09 break; X`09 case 15:`09/*Lose dexterity */ X`09 f_ptr = &py.flags; X`09 take_hit(damage, ddesc); X`09 if (f_ptr->sustain_dex) X`09`09msg_print("You feel clumsy for a moment, but it passes."); X`09 else X`09`09`7B X`09`09 msg_print("You feel more clumsy."); X`09`09 (void) dec_stat (A_DEX); X`09`09`7D X`09 break; X`09 case 16:`09/*Lose constitution */ X`09 f_ptr = &py.flags; X`09 take_hit(damage, ddesc); X`09 if (f_ptr->sustain_con) X`09`09msg_print("Your body resists the effects of the disease."); X`09 else X`09`09`7B X`09`09 msg_print("Your health is damaged!"); X`09`09 (void) dec_stat (A_CON); X`09`09`7D X`09 break; X`09 case 17:`09/*Lose intelligence */ X`09 f_ptr = &py.flags; X`09 take_hit(damage, ddesc); X`09 msg_print("You have trouble thinking clearly."); X`09 if (f_ptr->sustain_int) X`09`09msg_print("But your mind quickly clears."); X`09 else X`09`09(void) dec_stat (A_INT); X`09 break; X`09 case 18:`09/*Lose wisdom`09 */ X`09 f_ptr = &py.flags; X`09 take_hit(damage, ddesc); X`09 if (f_ptr->sustain_wis) X`09`09msg_print("Your wisdom is sustained."); X`09 else X`09`09`7B X`09`09 msg_print("Your wisdom is drained."); X`09`09 (void) dec_stat (A_WIS); X`09`09`7D X`09 break; X`09 case 19:`09/*Lose experience */ X`09 msg_print("You feel your life draining away!"); X`09 lose_exp(damage + (py.misc.exp / 100)*MON_DRAIN_LIFE); X`09 break; X`09 case 20:`09/*Aggravate monster*/ X`09 (void) aggravate_monster(20); X`09 break; X`09 case 21:`09/*Disenchant`09 */ X`09 flag = FALSE; X`09 switch(randint(7)) X`09`09`7B X`09`09case 1: i = INVEN_WIELD; break; X`09`09case 2: i = INVEN_BODY;`09 break; X`09`09case 3: i = INVEN_ARM;`09 break; X`09`09case 4: i = INVEN_OUTER; break; X`09`09case 5: i = INVEN_HANDS; break; X`09`09case 6: i = INVEN_HEAD;`09 break; X`09`09case 7: i = INVEN_FEET;`09 break; X`09`09`7D X`09 i_ptr = &inventory`5Bi`5D; X`09 if (i_ptr->tohit > 0) X`09`09`7B X`09`09 i_ptr->tohit -= randint(2); X`09`09 /* don't send it below zero */ X`09`09 if (i_ptr->tohit < 0) X`09`09 i_ptr->tohit = 0; X`09`09 flag = TRUE; X`09`09`7D X`09 if (i_ptr->todam > 0) X`09`09`7B X`09`09 i_ptr->todam -= randint(2); X`09`09 /* don't send it below zero */ X`09`09 if (i_ptr->todam < 0) X`09`09 i_ptr->todam = 0; X`09`09 flag = TRUE; X`09`09`7D X`09 if (i_ptr->toac > 0) X`09`09`7B X`09`09 i_ptr->toac -= randint(2); X`09`09 /* don't send it below zero */ X`09`09 if (i_ptr->toac < 0) X`09`09 i_ptr->toac = 0; X`09`09 flag = TRUE; X`09`09`7D X`09 if (flag) X`09`09`7B X`09`09 msg_print("There is a static feeling in the air."); X`09`09 calc_bonuses (); X`09`09`7D X`09 else X`09`09notice = FALSE; X`09 break; X`09 case 22:`09/*Eat food`09 */ X`09 if (find_range(TV_FOOD, TV_NEVER, &i, &j)) X`09`09`7B X`09`09 inven_destroy(i); X`09`09 msg_print ("It got at your rations!"); X`09`09`7D X`09 else X`09`09notice = FALSE; X`09 break; X`09 case 23:`09/*Eat light`09 */ X`09 i_ptr = &inventory`5BINVEN_LIGHT`5D; X`09 if (i_ptr->p1 > 0) X`09`09`7B X`09`09 i_ptr->p1 -= (250 + randint(250)); X`09`09 if (i_ptr->p1 < 1) i_ptr->p1 = 1; X`09`09 if (py.flags.blind < 1) X`09`09 msg_print("Your light dims."); X`09`09 else X`09`09 notice = FALSE; X`09`09`7D X`09 else X`09`09notice = FALSE; X`09 break; X`09 case 24:`09/*Eat charges`09 */ X`09 i = randint(inven_ctr) - 1; X`09 j = r_ptr->level; X`09 i_ptr = &inventory`5Bi`5D; X`09 if (((i_ptr->tval == TV_STAFF) `7C`7C (i_ptr->tval == TV_WAND)) X`09`09 && (i_ptr->p1 > 0)) X`09`09`7B X`09`09 m_ptr->hp += j*i_ptr->p1; X`09`09 i_ptr->p1 = 0; X`09`09 if (! known2_p (i_ptr)) X`09`09 add_inscribe (i_ptr, ID_EMPTY); X`09`09 msg_print("Energy drains from your pack!"); X`09`09`7D X`09 else X`09`09notice = FALSE; X`09 break; X`09 case 99: X`09 notice = FALSE; X`09 break; X`09 default: X`09 notice = FALSE; X`09 break; X`09 `7D X X`09 /* Moved here from mon_move, so that monster only confused if it X`09 actually hits. A monster that has been repelled has not hit X`09 the player, so it should not be confused. */ X`09 if (py.flags.confuse_monster && adesc != 99) X`09 `7B X`09 msg_print("Your hands stop glowing."); X`09 py.flags.confuse_monster = FALSE; X`09 if ((randint(MAX_MONS_LEVEL) < r_ptr->level) `7C`7C X`09`09 (CD_NO_SLEEP & r_ptr->cdefense)) X`09`09(void) sprintf(tmp_str, "%sis unaffected.", cdesc); X`09 else X`09`09`7B X`09`09 (void) sprintf(tmp_str, "%sappears confused.", cdesc); X`09`09 m_ptr->confused = TRUE; X`09`09`7D X`09 msg_print(tmp_str); X`09 if (visible && !death && randint(4) == 1) X`09`09c_recall`5Bm_ptr->mptr`5D.r_cdefense `7C= r_ptr->cdefense & X`09`09 CD_NO_SLEEP; X`09 `7D X X`09 /* increase number of attacks if notice true, or if visible and had X`09 previously noticed the attack (in which case all this does is X`09 help player learn damage), note that in the second case do X`09 not increase attacks if creature repelled (no damage done) */ X`09 if ((notice `7C`7C X`09 (visible && c_recall`5Bm_ptr->mptr`5D.r_attacks`5Battackn`5D != 0 V && X`09`09attype != 99)) X`09 && c_recall`5Bm_ptr->mptr`5D.r_attacks`5Battackn`5D < MAX_UCHAR) X`09 c_recall`5Bm_ptr->mptr`5D.r_attacks`5Battackn`5D++; X`09 if (death && c_recall`5Bm_ptr->mptr`5D.r_deaths < MAX_SHORT) X`09 c_recall`5Bm_ptr->mptr`5D.r_deaths++; X`09`7D X else X`09`7B X`09 if ((adesc >= 1 && adesc <= 3) `7C`7C (adesc == 6)) X`09 `7B X`09 disturb (1, 0); X`09 (void) strcpy(tmp_str, cdesc); X`09 msg_print(strcat(tmp_str, "misses you.")); X`09 `7D X`09`7D X if (attackn < MAX_MON_NATTACK-1) X`09attackn++; X else X`09break; X `7D X`7D X X X/* Make the move if possible, five choices`09`09-RAK-`09*/ Xstatic void make_move(monptr, mm, rcmove) Xint monptr; Xint *mm; Xint32u *rcmove; X`7B X int i, newy, newx, do_turn, do_move, stuck_door; X int32u movebits; X register cave_type *c_ptr; X register monster_type *m_ptr; X register inven_type *t_ptr; X#ifdef ATARIST_MWC X int32u holder; X#endif X X i = 0; X do_turn = FALSE; X do_move = FALSE; X m_ptr = &m_list`5Bmonptr`5D; X movebits = c_list`5Bm_ptr->mptr`5D.cmove; X do X `7B X /* Get new position`09`09*/ X newy = m_ptr->fy; X newx = m_ptr->fx; X (void) mmove(mm`5Bi`5D, &newy, &newx); X c_ptr = &cave`5Bnewy`5D`5Bnewx`5D; X if (c_ptr->fval != BOUNDARY_WALL) X`09`7B X`09 /* Floor is open?`09`09 */ X`09 if (c_ptr->fval <= MAX_OPEN_SPACE) X`09 do_move = TRUE; X`09 /* Creature moves through walls? */ X#ifdef ATARIST_MWC X`09 else if (movebits & (holder = CM_PHASE)) X#else X`09 else if (movebits & CM_PHASE) X#endif X`09 `7B X`09 do_move = TRUE; X#ifdef ATARIST_MWC X`09 *rcmove `7C= holder; X#else X`09 *rcmove `7C= CM_PHASE; X#endif X`09 `7D X`09 /* Creature can open doors?`09 */ X`09 else if (c_ptr->tptr != 0) X`09 `7B X`09 t_ptr = &t_list`5Bc_ptr->tptr`5D; X#ifdef ATARIST_MWC X`09 if (movebits & (holder = CM_OPEN_DOOR)) X#else X`09 if (movebits & CM_OPEN_DOOR) X#endif X`09`09`7B /* Creature can open doors.`09`09 */ X`09`09 stuck_door = FALSE; X`09`09 if (t_ptr->tval == TV_CLOSED_DOOR) X`09`09 `7B X`09`09 do_turn = TRUE; X`09`09 if (t_ptr->p1 == 0)`09`09/* Closed doors`09 */ X`09`09`09do_move = TRUE; X`09`09 else if (t_ptr->p1 > 0)`09 /* Locked doors`09*/ X`09`09`09`7B X`09`09`09 if (randint((m_ptr->hp+1)*(50+t_ptr->p1)) < X`09`09`09 40*(m_ptr->hp-10-t_ptr->p1)) X`09`09`09 t_ptr->p1 = 0; X`09`09`09`7D X`09`09 else if (t_ptr->p1 < 0)`09 /* Stuck doors`09*/ X`09`09`09`7B X`09`09`09 if (randint((m_ptr->hp+1)*(50-t_ptr->p1)) < X`09`09`09 40*(m_ptr->hp-10+t_ptr->p1)) X`09`09`09 `7B X`09`09`09 msg_print("You hear a door burst open!"); X`09`09`09 disturb (1, 0); X`09`09`09 stuck_door = TRUE; X`09`09`09 do_move = TRUE; X`09`09`09 `7D X`09`09`09`7D X`09`09 `7D X`09`09 else if (t_ptr->tval == TV_SECRET_DOOR) X`09`09 `7B X`09`09 do_turn = TRUE; X`09`09 do_move = TRUE; X`09`09 `7D X`09`09 if (do_move) X`09`09 `7B X`09`09 invcopy(t_ptr, OBJ_OPEN_DOOR); X`09`09 if (stuck_door) /* 50% chance of breaking door */ X`09`09`09t_ptr->p1 = 1 - randint(2); X`09`09 c_ptr->fval = CORR_FLOOR; X`09`09 lite_spot(newy, newx); X#ifdef ATARIST_MWC X`09`09 *rcmove `7C= holder; X#else X`09`09 *rcmove `7C= CM_OPEN_DOOR; X#endif X`09`09 do_move = FALSE; X`09`09 `7D X`09`09`7D X`09 else X`09`09`7B /* Creature can not open doors, must bash them */ X`09`09 if (t_ptr->tval == TV_CLOSED_DOOR) X`09`09 `7B X`09`09 do_turn = TRUE; X`09`09 if (randint((m_ptr->hp+1)*(80+abs(t_ptr->p1))) < X`09`09`09 40*(m_ptr->hp-20-abs(t_ptr->p1))) X`09`09`09`7B X`09`09`09 invcopy(t_ptr, OBJ_OPEN_DOOR); X`09`09`09 /* 50% chance of breaking door */ X`09`09`09 t_ptr->p1 = 1 - randint(2); X`09`09`09 c_ptr->fval = CORR_FLOOR; X`09`09`09 lite_spot(newy, newx); X`09`09`09 msg_print ("You hear a door burst open!"); X`09`09`09 disturb (1, 0); X`09`09`09`7D X`09`09 `7D X`09`09`7D X`09 `7D X`09 /* Glyph of warding present?`09 */ X`09 if (do_move && (c_ptr->tptr != 0) && X`09 (t_list`5Bc_ptr->tptr`5D.tval == TV_VIS_TRAP) && X`09 (t_list`5Bc_ptr->tptr`5D.subval == 99)) X`09 `7B X`09 if (randint(OBJ_RUNE_PROT) < c_list`5Bm_ptr->mptr`5D.level) X`09`09`7B X`09`09 if ((newy==char_row) && (newx==char_col)) X`09`09 msg_print("The rune of protection is broken!"); X`09`09 (void) delete_object(newy, newx); X`09`09`7D X`09 else X`09`09`7B X`09`09 do_move = FALSE; X`09`09 /* If the creature moves only to attack, */ X`09`09 /* don't let it move if the glyph prevents */ X`09`09 /* it from attacking */ X`09`09 if (movebits & CM_ATTACK_ONLY) X`09`09 do_turn = TRUE; X`09`09`7D X`09 `7D X`09 /* Creature has attempted to move on player?`09 */ X`09 if (do_move) X`09 if (c_ptr->cptr == 1) X`09 `7B X`09`09/* if the monster is not lit, must call update_mon, it may X`09`09 be faster than character, and hence could have just X`09`09 moved next to character this same turn */ X`09`09if (!m_ptr->ml) X`09`09 update_mon(monptr); X`09`09make_attack(monptr); X`09`09do_move = FALSE; X`09`09do_turn = TRUE; X`09 `7D X`09 /* Creature is attempting to move on other creature?`09 */ X`09 else if ((c_ptr->cptr > 1) && X`09`09 ((newy != m_ptr->fy) `7C`7C X`09`09 (newx != m_ptr->fx))) X`09 `7B X`09`09/* Creature eats other creatures?`09 */ X#ifdef ATARIST_MWC X`09`09if ((movebits & (holder = CM_EATS_OTHER)) && X#else X`09`09if ((movebits & CM_EATS_OTHER) && X#endif X`09`09 (c_list`5Bm_ptr->mptr`5D.mexp >= X`09`09 c_list`5Bm_list`5Bc_ptr->cptr`5D.mptr`5D.mexp)) X`09`09 `7B X`09`09 if (m_list`5Bc_ptr->cptr`5D.ml) X#ifdef ATARIST_MWC X`09`09 *rcmove `7C= holder; X#else X`09`09 *rcmove `7C= CM_EATS_OTHER; X#endif X`09`09 /* It ate an already processed monster. Handle normally. */ X`09`09 if (monptr < c_ptr->cptr) X`09`09 delete_monster((int) c_ptr->cptr); X`09`09 /* If it eats this monster, an already processed monster X`09`09 will take its place, causing all kinds of havoc. Delay X`09`09 the kill a bit. */ X`09`09 else X`09`09 fix1_delete_monster((int) c_ptr->cptr); X`09`09 `7D X`09`09else X`09`09 do_move = FALSE; X`09 `7D X`09 /* Creature has been allowed move.`09 */ X`09 if (do_move) X`09 `7B X`09 /* Pick up or eat an object`09 */ X#ifdef ATARIST_MWC X`09 if (movebits & (holder = CM_PICKS_UP)) X#else X`09 if (movebits & CM_PICKS_UP) X#endif X`09`09`7B X`09`09 c_ptr = &cave`5Bnewy`5D`5Bnewx`5D; X X`09`09 if ((c_ptr->tptr != 0) X`09`09 && (t_list`5Bc_ptr->tptr`5D.tval <= TV_MAX_OBJECT)) X`09`09 `7B X#ifdef ATARIST_MWC X`09`09 *rcmove `7C= holder; X#else X`09`09 *rcmove `7C= CM_PICKS_UP; X#endif X`09`09 (void) delete_object(newy, newx); X`09`09 `7D X`09`09`7D X`09 /* Move creature record`09`09 */ X`09 move_rec((int)m_ptr->fy, (int)m_ptr->fx, newy, newx); X`09 if (m_ptr->ml) X`09`09`7B X`09`09 m_ptr->ml = FALSE; X`09`09 lite_spot ((int)m_ptr->fy, (int)m_ptr->fx); X`09`09`7D X`09 m_ptr->fy = newy; X`09 m_ptr->fx = newx; X`09 m_ptr->cdis = distance (char_row, char_col, newy, newx); X`09 do_turn = TRUE; X`09 `7D X`09`7D X i++; X /* Up to 5 attempts at moving, give up.`09 */ X `7D X while ((!do_turn) && (i < 5)); X`7D X X X/* Creatures can cast spells too. (Dragon Breath)`09-RAK-`09*/ X/* cast_spell = true if creature changes position`09*/ X/* took_turn = true if creature casts a spell`09`09*/ Xstatic void mon_cast_spell(monptr, took_turn) Xint monptr; Xint *took_turn; X`7B X int32u i; X int y, x, chance, thrown_spell, r1; X register int k; X int spell_choice`5B30`5D; X vtype cdesc, outval, ddesc; X register monster_type *m_ptr; X register creature_type *r_ptr; X#ifdef ATARIST_MWC X int32u holder; X#endif X X if (death) X return; X X m_ptr = &m_list`5Bmonptr`5D; X r_ptr = &c_list`5Bm_ptr->mptr`5D; X chance = (int)(r_ptr->spells & CS_FREQ); X /* 1 in x chance of casting spell`09`09 */ +-+-+-+-+-+-+-+- END OF PART 6 +-+-+-+-+-+-+-+-