/* * Lose experience */ void lose_exp(s32b amount) { /* Never drop below zero experience */ if (amount > p_ptr->exp) amount = p_ptr->exp; /* Lose some experience */ p_ptr->exp -= amount; /* Check Experience */ check_experience(); }
/** * Gain experience */ void gain_exp(s32b amount) { /* Gain some experience */ p_ptr->exp += amount; /* Slowly recover from experience drainage */ if (p_ptr->exp < p_ptr->max_exp) { /* Gain max experience (10%) */ p_ptr->max_exp += amount / 10; } /* Check Experience */ check_experience(); }
void mimic_race(int new_race, const char *msg) { int old_race = p_ptr->mimic_form; if (p_ptr->prace != RACE_DOPPELGANGER) return; if (p_ptr->tim_mimic) return; if (new_race == old_race) return; if (msg) msg_print(msg); if (old_race == RACE_HUMAN || old_race == RACE_DEMIGOD) { int i, idx; for (i = 0; i < MAX_DEMIGOD_POWERS; i++) { idx = p_ptr->demigod_power[i]; if (idx >= 0) { mut_unlock(idx); mut_lose(idx); /* Lose the mutation, but not the choice! p_ptr->demigod_power[i] = -1; */ } } } /* Shifting form causes mutations to vanish! */ mut_lose_all(); if (new_race == MIMIC_NONE) msg_print("You resume your true form."); else { race_t *race_ptr = get_race_t_aux(new_race, 0); if (is_a_vowel(race_ptr->name[0])) msg_format("You turn into an %s!", race_ptr->name); else msg_format("You turn into a %s!", race_ptr->name); } p_ptr->mimic_form = new_race; p_ptr->expfact = calc_exp_factor(); check_experience(); if (new_race == RACE_HUMAN || new_race == RACE_DEMIGOD) { get_race_t()->gain_level(p_ptr->lev); /* This is OK ... Just make sure we get to choose racial powers on mimicry */ } if (new_race == RACE_BEASTMAN) { int i; mut_gain_random(mut_good_pred); for (i = 2; i <= p_ptr->lev; i++) { if (one_in_(5)) mut_gain_random(NULL); } } p_ptr->redraw |= (PR_BASIC | PR_STATUS | PR_MAP); p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA); equip_on_change_race(); reset_visuals(); handle_stuff(); }
/* * Aux function for "do_cmd_wiz_change()". -RAK- */ static void do_cmd_wiz_change_aux(void) { int i; int tmp_int; long tmp_long; char tmp_val[160]; char ppp[80]; /* Query the stats */ for (i = 0; i < A_MAX; i++) { /* Prompt */ sprintf(ppp, "%s (3-118): ", stat_names[i]); /* Default */ sprintf(tmp_val, "%d", p_ptr->stat_max[i]); /* Query */ if (!get_string(ppp, tmp_val, 3)) return; /* Extract */ tmp_int = atoi(tmp_val); /* Verify */ if (tmp_int > 18+100) tmp_int = 18+100; else if (tmp_int < 3) tmp_int = 3; /* Save it */ p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int; } /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->au)); /* Query */ if (!get_string("Gold: ", tmp_val, 9)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; /* Save */ p_ptr->au = tmp_long; /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp)); /* Query */ if (!get_string("Experience: ", tmp_val, 9)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; /* Save */ p_ptr->max_exp = tmp_long; p_ptr->exp = tmp_long; /* Update */ check_experience(); }
/*! * @brief プレイヤーの現能力値を調整する * Aux function for "do_cmd_wiz_change()". -RAK- * @return なし */ static void do_cmd_wiz_change_aux(void) { int i, j; int tmp_int; long tmp_long; s16b tmp_s16b; char tmp_val[160]; char ppp[80]; /* Query the stats */ for (i = 0; i < 6; i++) { /* Prompt */ sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]); /* Default */ sprintf(tmp_val, "%d", p_ptr->stat_max[i]); /* Query */ if (!get_string(ppp, tmp_val, 3)) return; /* Extract */ tmp_int = atoi(tmp_val); /* Verify */ if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i]; else if (tmp_int < 3) tmp_int = 3; /* Save it */ p_ptr->stat_cur[i] = p_ptr->stat_max[i] = tmp_int; } /* Default */ sprintf(tmp_val, "%d", WEAPON_EXP_MASTER); /* Query */ if (!get_string(_("熟練度: ", "Proficiency: "), tmp_val, 9)) return; /* Extract */ tmp_s16b = atoi(tmp_val); /* Verify */ if (tmp_s16b < WEAPON_EXP_UNSKILLED) tmp_s16b = WEAPON_EXP_UNSKILLED; if (tmp_s16b > WEAPON_EXP_MASTER) tmp_s16b = WEAPON_EXP_MASTER; for (j = 0; j <= TV_WEAPON_END - TV_WEAPON_BEGIN; j++) { for (i = 0;i < 64;i++) { p_ptr->weapon_exp[j][i] = tmp_s16b; if (p_ptr->weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) p_ptr->weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i]; } } for (j = 0; j < 10; j++) { p_ptr->skill_exp[j] = tmp_s16b; if (p_ptr->skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) p_ptr->skill_exp[j] = s_info[p_ptr->pclass].s_max[j]; } for (j = 0; j < 32; j++) p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b); for (; j < 64; j++) p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b); /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->au)); /* Query */ if (!get_string("Gold: ", tmp_val, 9)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; /* Save */ p_ptr->au = tmp_long; /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp)); /* Query */ if (!get_string("Experience: ", tmp_val, 9)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; if (p_ptr->prace != RACE_ANDROID) { /* Save */ p_ptr->max_exp = tmp_long; p_ptr->exp = tmp_long; /* Update */ check_experience(); } }
/* * Aux function for "do_cmd_wiz_change()" */ static void do_cmd_wiz_change_aux(void) { int i; int tmp_int; long tmp_long; char tmp_val[160]; char ppp[80]; /* Query the stats */ for (i = 0; i < A_MAX; i++) { /* Prompt */ strnfmt(ppp, sizeof(ppp), "%s (%d to %d): ", stat_names[i], BASE_STAT_MIN, BASE_STAT_MAX); /* Default */ sprintf(tmp_val, "%d", p_ptr->stat_base[i]); /* Query */ if (!term_get_string(ppp, tmp_val, 4)) return; /* Extract */ tmp_int = atoi(tmp_val); /* Verify */ if (tmp_int > BASE_STAT_MAX) tmp_int = BASE_STAT_MAX; else if (tmp_int < BASE_STAT_MIN) tmp_int = BASE_STAT_MIN; /* Save it */ p_ptr->stat_base[i] = tmp_int; p_ptr->stat_drain[i] = 0; } /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->new_exp)); /* Query */ if (!term_get_string("Experience Pool: ", tmp_val, 10)) return; /* Extract */ tmp_long = atol(tmp_val); /* Verify */ if (tmp_long < 0) tmp_long = 0L; /* Update total Exp */ p_ptr->exp += tmp_long - p_ptr->new_exp; /* Save */ p_ptr->new_exp = tmp_long; /* Update */ check_experience(); /* Default */ sprintf(tmp_val, "%ld", (long)(p_ptr->game_type)); /* Query */ if (!term_get_string("Game Type: ", tmp_val, 10)) return; /* Extract */ tmp_long = atol(tmp_val); /* Update game type */ p_ptr->game_type = tmp_long; }
EditCharacterDialog::EditCharacterDialog(void) { QPointer<QGridLayout> edit_info = new QGridLayout; QPointer<QVBoxLayout> vlay = new QVBoxLayout; // First allow the 6 stats to be edited // Strength QPointer<QLabel> str_label = new QLabel("Strength"); QPointer<QSpinBox> str_spinner = new QSpinBox; str_spinner->setRange(3,118); str_spinner->setValue(p_ptr->stat_base_cur[A_STR]); edit_info->addWidget(str_label, 1, 0); edit_info->addWidget(str_spinner, 1, 1); // Intelligence QPointer<QLabel> int_label = new QLabel("Intelligence"); QPointer<QSpinBox> int_spinner = new QSpinBox; int_spinner->setRange(3,118); int_spinner->setValue(p_ptr->stat_base_cur[A_INT]); edit_info->addWidget(int_label, 2, 0); edit_info->addWidget(int_spinner, 2, 1); // Wisdom QPointer<QLabel> wis_label = new QLabel("Wisdom"); QPointer<QSpinBox> wis_spinner = new QSpinBox; wis_spinner->setRange(3,118); wis_spinner->setValue(p_ptr->stat_base_cur[A_WIS]); edit_info->addWidget(wis_label, 3, 0); edit_info->addWidget(wis_spinner, 3, 1); // Dexterity QPointer<QLabel> dex_label = new QLabel("Dexterity"); QPointer<QSpinBox> dex_spinner = new QSpinBox; dex_spinner->setRange(3,118); dex_spinner->setValue(p_ptr->stat_base_cur[A_DEX]); edit_info->addWidget(dex_label, 4, 0); edit_info->addWidget(dex_spinner, 4, 1); // Constitution QPointer<QLabel> con_label = new QLabel("Constitution"); QPointer<QSpinBox> con_spinner = new QSpinBox; con_spinner->setRange(3,118); con_spinner->setValue(p_ptr->stat_base_cur[A_CON]); edit_info->addWidget(con_label, 5, 0); edit_info->addWidget(con_spinner, 5, 1); // Charisma QPointer<QLabel> chr_label = new QLabel("Charisma"); QPointer<QSpinBox> chr_spinner = new QSpinBox; chr_spinner->setRange(3,118); chr_spinner->setValue(p_ptr->stat_base_cur[A_CHR]); edit_info->addWidget(chr_label, 6, 0); edit_info->addWidget(chr_spinner, 6, 1); // Gold QPointer<QLabel> gold_label = new QLabel("Gold"); QPointer<QSpinBox> gold_spinner = new QSpinBox; gold_spinner->setRange(0,500000000); gold_spinner->setValue(p_ptr->au); gold_spinner->setSingleStep(1000000); edit_info->addWidget(gold_label, 7, 0); edit_info->addWidget(gold_spinner, 7, 1); // Experience QPointer<QLabel> exp_label = new QLabel("Experience"); QPointer<QSpinBox> exp_spinner = new QSpinBox; exp_spinner->setRange(0,10000000); exp_spinner->setValue(p_ptr->max_exp); exp_spinner->setSingleStep(10000); edit_info->addWidget(exp_label, 8, 0); edit_info->addWidget(exp_spinner, 8, 1); // Experience QPointer<QLabel> fame_label = new QLabel("Fame"); QPointer<QSpinBox> fame_spinner = new QSpinBox; fame_spinner->setRange(0,5000); fame_spinner->setValue(p_ptr->q_fame); fame_spinner->setSingleStep(100); edit_info->addWidget(fame_label, 9, 0); edit_info->addWidget(fame_spinner, 9, 1); QPointer<QPushButton> close_button = new QPushButton(tr("&Close")); connect(close_button, SIGNAL(clicked()), this, SLOT(close())); vlay->addLayout(edit_info); vlay->addStretch(); vlay->addWidget(close_button); setLayout(vlay); setWindowTitle(tr("Character Edit Screen")); this->exec(); p_ptr->stat_base_cur[A_STR] = p_ptr->stat_base_max[A_STR] = str_spinner->value(); p_ptr->stat_base_cur[A_INT] = p_ptr->stat_base_max[A_INT] = int_spinner->value(); p_ptr->stat_base_cur[A_WIS] = p_ptr->stat_base_max[A_WIS] = wis_spinner->value(); p_ptr->stat_base_cur[A_DEX] = p_ptr->stat_base_max[A_DEX] = dex_spinner->value(); p_ptr->stat_base_cur[A_CON] = p_ptr->stat_base_max[A_CON] = con_spinner->value(); p_ptr->stat_base_cur[A_CHR] = p_ptr->stat_base_max[A_CHR] = chr_spinner->value(); p_ptr->au = gold_spinner->value(); p_ptr->max_exp = p_ptr->exp = exp_spinner->value(); check_experience(); p_ptr->q_fame = fame_spinner->value(); /* Combine and Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER); /* Update stuff */ p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); /* Fully update the visuals */ p_ptr->update |= (PU_FORGET_VIEW | PU_UPDATE_VIEW | PU_MONSTERS); /* Redraw everything */ p_ptr->redraw |= (PR_STATUSBAR | PR_SIDEBAR_PL | PR_MAP | PR_WIN_INVENTORY | PR_WIN_EQUIPMENT | PR_MESSAGES | PR_WIN_MON_RECALL | PR_WIN_OBJ_RECALL | PR_WIN_MESSAGES | PR_WIN_OBJLIST | PR_WIN_FEAT_RECALL); handle_stuff(); }
/* * Wield or wear a single item from the pack or floor */ void do_cmd_wield(void) { int i, item, slot; object_type forge; object_type *q_ptr; object_type *o_ptr; cptr act; char o_name[MAX_NLEN]; cptr q, s; bool newrace = FALSE; /* Restrict the choices */ item_tester_hook = item_tester_hook_wear; /* Get an item */ #ifdef JP q = "どれを装備しますか? "; s = "装備可能なアイテムがない。"; #else q = "Wear/Wield which item? "; s = "You have nothing you can wear or wield."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Check the slot */ slot = wield_slot(o_ptr); /* Where is the item now */ if (slot == INVEN_WIELD) { #ifdef JP act = "を打撃用に装備した"; #else act = "You are wielding"; #endif } else if (slot == INVEN_BOW) { #ifdef JP act = "を射撃用に装備した"; #else act = "You are shooting with"; #endif } else if (slot == INVEN_LITE) { #ifdef JP act = "を光源にした"; #else act = "Your light source is"; #endif } else { #ifdef JP act = "を装備した"; #else act = "You are wearing"; #endif } if ((o_ptr->tval == TV_RING) && inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx) { /* Restrict the choices */ item_tester_tval = TV_RING; /* Choose a ring from the equipment only */ #ifdef JP q = "どちらの指輪と取り替えますか?"; s = "おっと。"; #else q = "Replace which ring? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } if (slot == INVEN_WIELD) { if (is_two_handed()) { /* Restrict the choices */ item_tester_hook = item_tester_hook_melee_weapon; /* Choose a ring from the equipment only */ #ifdef JP q = "どちらの武器と取り替えますか?"; s = "おっと。"; #else q = "Replace which weapon? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } else if (inventory[slot].k_idx) { /* Confirm doing two handed combat */ #ifdef JP if (get_check("二刀流を行いますか?")) #else if (get_check("Do you want to do two handed combat?")) #endif { slot = INVEN_ARM; } } } /* Prevent wielding into a cursed slot */ if (cursed_p(&inventory[slot])) { /* Describe it */ object_desc(o_name, &inventory[slot], OD_OMIT_PREFIX | OD_NAME_ONLY); /* Message */ #ifdef JP msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name ); #else msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); #endif /* Cancel the command */ return; } if (cursed_p(o_ptr) && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE))) { char dummy[512]; /* Describe it */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY); #ifdef JP sprintf(dummy, "本当に%s{呪われている}を使いますか?", o_name); #else sprintf(dummy, "Really use the %s {cursed}? ", o_name); #endif if (!get_check(dummy)) return; } #if 0 if ((o_ptr->name1 == ART_STONEMASK) && object_known_p(o_ptr) && (p_ptr->prace != RACE_VAMPIRE)) { char dummy[MAX_NLEN+80]; /* Describe it */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY); #ifdef JP sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name); #else msg_format("%s will transforms you into a vampire permanently when equiped.", o_name); sprintf(dummy, "Do you become a vampire?"); #endif if (!get_check(dummy)) return; } #endif /* Check if completed a quest */ for (i = 0; i < max_quests; i++) { if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) && (quest[i].status == QUEST_STATUS_TAKEN) && (quest[i].k_idx == o_ptr->name1)) { quest[i].status = QUEST_STATUS_COMPLETED; quest[i].complev = (byte)p_ptr->lev; #ifdef JP msg_print("クエストを達成した!"); #else msg_print("You completed your quest!"); #endif sound(SOUND_LEVEL); /* (Sound substitute) No quest sound */ msg_print(NULL); } } /* Take a turn */ energy_use = 100; /* Get local object */ q_ptr = &forge; /* Obtain local object */ object_copy(q_ptr, o_ptr); /* Modify quantity */ q_ptr->number = 1; /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_optimize(0 - item); } /* Access the wield slot */ o_ptr = &inventory[slot]; /* Take off existing item */ if (o_ptr->k_idx) { /* Take off existing item */ (void)inven_takeoff(slot, 255); } /* Wear the new stuff */ object_copy(o_ptr, q_ptr); /* Player touches it */ o_ptr->marked |= OM_TOUCHED; /* Forget stack */ o_ptr->next_o_idx = 0; /* Forget location */ o_ptr->iy = o_ptr->ix = 0; /* Increase the weight */ p_ptr->total_weight += q_ptr->weight; /* Increment the equip counter by hand */ equip_cnt++; /* Describe the result */ object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP msg_format("%s(%c)%s。", o_name, index_to_label(slot), act ); #else msg_format("%s %s (%c).", act, o_name, index_to_label(slot)); #endif sound(SOUND_WIELD); /* Cursed! */ if (cursed_p(o_ptr)) { /* Warn the player */ #ifdef JP msg_print("うわ! すさまじく冷たい!"); #else msg_print("Oops! It feels deathly cold!"); #endif sound(SOUND_CURSED); /* Note the curse */ o_ptr->ident |= (IDENT_SENSE); } #if 0 /* if you weild stonemask, you morph into vampire */ if ((o_ptr->name1 == ART_STONEMASK) && (!is_undead())) { p_ptr->prace = RACE_VAMPIRE; newrace = TRUE; #ifdef JP msg_format("あなたは吸血鬼に変化した!"); #else msg_format("You polymorphed into a vampire!"); #endif } #endif if (newrace) { rp_ptr = &race_info[p_ptr->prace]; /* Experience factor */ calc_expfact(); /* Get new height and weight */ get_ahw(FALSE); check_experience(); /* Hitdice */ p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp; do_cmd_rerate(TRUE); p_ptr->redraw |= (PR_BASIC); p_ptr->update |= (PU_BONUS); handle_stuff(); /* Load an autopick preference file */ autopick_load_pref(FALSE); lite_spot(py, px); } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Recalculate mana */ p_ptr->update |= (PU_MANA); p_ptr->redraw |= (PR_EQUIPPY); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER | PW_STATS); }