/* * Advance experience levels and print experience */ void check_experience(void) { /* Hack -- lower limit */ if (p_ptr->exp < 0) p_ptr->exp = 0; /* Hack -- lower limit */ if (p_ptr->max_exp < 0) p_ptr->max_exp = 0; /* Hack -- upper limit */ if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP; /* Hack -- upper limit */ if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP; /* Hack -- maintain "max" experience */ if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp; /* Redraw experience */ p_ptr->redraw |= (PR_EXP); /* Handle stuff */ handle_stuff(); /* Lose levels while possible */ while ((p_ptr->lev > 1) && (p_ptr->exp < (get_experience_by_level(p_ptr->lev-2) * p_ptr->expfact / 100L))) { /* Lose a level */ p_ptr->lev--; /* Update some stuff */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); /* Redraw some stuff */ p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_MONSTER); /* Handle stuff */ handle_stuff(); } /* Gain levels while possible */ while ((p_ptr->lev < z_info->max_level) && (p_ptr->exp >= (get_experience_by_level(p_ptr->lev-1) * p_ptr->expfact / 100L))) { /* Gain a level */ p_ptr->lev++; /* Message */ message_format(MSG_LEVEL, p_ptr->lev, "Welcome to level %d.", p_ptr->lev); /* Save the highest level*/ if (p_ptr->lev > p_ptr->max_lev) { /* update the highest level*/ p_ptr->max_lev = p_ptr->lev; /* If auto-note taking enabled, write a note to the file every 5th level. */ if ((adult_take_notes) && ((p_ptr->lev % 5) == 0)) { char buf[120]; /* Build the message */ sprintf(buf, "Reached level %d", p_ptr->lev); /* Write message */ do_cmd_note(buf, p_ptr->depth); } } /* Update some stuff */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); /* Redraw some stuff */ p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP | PR_MONSTER); /* Handle stuff */ handle_stuff(); } /* Gain max levels while possible */ while ((p_ptr->max_lev < z_info->max_level) && (p_ptr->max_exp >= (get_experience_by_level(p_ptr->max_lev-1) * p_ptr->expfact / 100L))) { /* Gain max level */ p_ptr->max_lev++; /* Update some stuff */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); /* Redraw some stuff */ p_ptr->redraw |= (PR_LEV | PR_TITLE); /* Handle stuff */ handle_stuff(); } }
void prise_silmaril(void) { object_type *o_ptr; object_type *w_ptr; artefact_type *a_ptr; object_type object_type_body; cptr freed_msg = NULL; // default to soothe compiler warnings bool freed = FALSE; int slot = 0; int dam = 0; int prt = 0; int net_dam = 0; int prt_percent = 0; int hit_result = 0; int crit_bonus_dice = 0; int pd = 0; int noise = 0; u32b dummy_noticed_flag; int mds = p_ptr->mds; int attack_mod = p_ptr->skill_use[S_MEL]; char o_name[80]; // the Crown is on the ground o_ptr = &o_list[cave_o_idx[p_ptr->py][p_ptr->px]]; switch (o_ptr->name1) { case ART_MORGOTH_3: { pd = 15; noise = 5; freed_msg = "You have freed a Silmaril!"; break; } case ART_MORGOTH_2: { pd = 25; noise = 10; if (p_ptr->crown_shatter) freed_msg = "The fates be damned! You free a second Silmaril."; else freed_msg = "You free a second Silmaril."; break; } case ART_MORGOTH_1: { pd = 30; noise = 15; freed_msg = "You free the final Silmaril. You have a very bad feeling about this."; msg_print("Looking into the hallowed light of the final Silmaril, you are filled with a strange dread."); if (!get_check("Are you sure you wish to proceed? ")) return; break; } } /* Get the weapon */ w_ptr = &inventory[INVEN_WIELD]; // undo rapid attack penalties if (p_ptr->active_ability[S_MEL][MEL_RAPID_ATTACK]) { // undo strength adjustment to the attack mds = total_mds(w_ptr, 0); // undo the dexterity adjustment to the attack attack_mod += 3; } /* Test for hit */ hit_result = hit_roll(attack_mod, 0, PLAYER, NULL, TRUE); /* Make some noise */ stealth_score -= noise; // Determine damage if (hit_result > 0) { crit_bonus_dice = crit_bonus(hit_result, w_ptr->weight, &r_info[R_IDX_MORGOTH], S_MEL, FALSE); dam = damroll(p_ptr->mdd + crit_bonus_dice, mds); prt = damroll(pd, 4); prt_percent = prt_after_sharpness(w_ptr, &dummy_noticed_flag); prt = (prt * prt_percent) / 100; net_dam = dam - prt; /* No negative damage */ if (net_dam < 0) net_dam = 0; //update_combat_rolls1b(PLAYER, TRUE); update_combat_rolls2(p_ptr->mdd + crit_bonus_dice, mds, dam, pd, 4, prt, prt_percent, GF_HURT, TRUE); } // if you succeed in prising out a Silmaril... if (net_dam > 0) { freed = TRUE; switch (o_ptr->name1) { case ART_MORGOTH_3: { break; } case ART_MORGOTH_2: { if (!p_ptr->crown_shatter && one_in_(2)) { shatter_weapon(2); freed = FALSE; } break; } case ART_MORGOTH_1: { if (!p_ptr->crown_shatter) { shatter_weapon(3); freed = FALSE; } else { p_ptr->cursed = TRUE; } break; } } if (freed) { // change its type to that of the crown with one less silmaril o_ptr->name1--; // get the details of this new crown a_ptr = &a_info[o_ptr->name1]; // modify the existing crown object_into_artefact(o_ptr, a_ptr); // report success msg_print(freed_msg); // Get new local object o_ptr = &object_type_body; // Make Silmaril object_prep(o_ptr, lookup_kind(TV_LIGHT, SV_LIGHT_SILMARIL)); // Get it slot = inven_carry(o_ptr); /* Get the object again */ o_ptr = &inventory[slot]; /* Describe the object */ object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); /* Message */ msg_format("You have %s (%c).", o_name, index_to_label(slot)); // Break the truce (always) break_truce(TRUE); // add a note to the notes file do_cmd_note("Cut a Silmaril from Morgoth's crown", p_ptr->depth); } } // if you fail to prise out a Silmaril... else { msg_print("Try though you might, you were unable to free a Silmaril."); msg_print("Perhaps you should try again or use a different weapon."); if (pd == 15) msg_print("(The combat rolls window shows what is happening.)"); // Break the truce if creatures see break_truce(FALSE); } // check for taking of final Silmaril if ((pd == 30) && freed) { msg_print("Until you escape you must now roll twice for every skill check, taking the worse result each time."); msg_print("You hear a cry of veangance echo through the iron hells."); wake_all_monsters(0); } }