2 * @file random-art-pval-investor.cpp
3 * @brief ランダムアーティファクトにpvalを追加する処理
8 #include "artifact/random-art-pval-investor.h"
9 #include "artifact/random-art-bias-types.h"
10 #include "object-enchant/tr-types.h"
11 #include "object-hook/hook-weapon.h"
12 #include "sv-definition/sv-armor-types.h"
13 #include "system/object-type-definition.h"
14 #include "util/bit-flags-calculator.h"
16 static bool random_art_bias_strength(object_type *o_ptr)
18 if (o_ptr->art_flags.has(TR_STR))
21 o_ptr->art_flags.set(TR_STR);
25 static bool random_art_bias_intelligence(object_type *o_ptr)
27 if (o_ptr->art_flags.has(TR_INT))
30 o_ptr->art_flags.set(TR_INT);
34 static bool random_art_bias_wisdom(object_type *o_ptr)
36 if (o_ptr->art_flags.has(TR_WIS))
39 o_ptr->art_flags.set(TR_WIS);
43 static bool random_art_bias_dexterity(object_type *o_ptr)
45 if (o_ptr->art_flags.has(TR_DEX))
48 o_ptr->art_flags.set(TR_DEX);
52 static bool random_art_bias_constitution(object_type *o_ptr)
54 if (o_ptr->art_flags.has(TR_CON))
57 o_ptr->art_flags.set(TR_CON);
61 static bool random_art_bias_charisma(object_type *o_ptr)
63 if (o_ptr->art_flags.has(TR_CHR))
66 o_ptr->art_flags.set(TR_CHR);
70 static bool random_art_bias_magic_mastery(object_type *o_ptr)
72 if ((o_ptr->tval != TV_GLOVES) || o_ptr->art_flags.has(TR_MAGIC_MASTERY))
75 o_ptr->art_flags.set(TR_MAGIC_MASTERY);
79 static bool random_art_bias_stealth(object_type *o_ptr)
81 if (o_ptr->art_flags.has(TR_STEALTH))
84 o_ptr->art_flags.set(TR_STEALTH);
88 static bool random_art_bias_search(object_type *o_ptr)
90 if (o_ptr->art_flags.has(TR_SEARCH))
93 o_ptr->art_flags.set(TR_SEARCH);
97 static bool switch_random_art_bias(object_type *o_ptr)
99 switch (o_ptr->artifact_bias) {
101 return random_art_bias_strength(o_ptr) || random_art_bias_constitution(o_ptr) || random_art_bias_dexterity(o_ptr);
103 return random_art_bias_intelligence(o_ptr) || random_art_bias_magic_mastery(o_ptr);
105 return random_art_bias_dexterity(o_ptr) || random_art_bias_constitution(o_ptr) || random_art_bias_strength(o_ptr);
107 return random_art_bias_stealth(o_ptr) || random_art_bias_search(o_ptr);
109 return random_art_bias_strength(o_ptr);
111 return random_art_bias_intelligence(o_ptr);
114 return random_art_bias_wisdom(o_ptr);
116 return random_art_bias_dexterity(o_ptr);
118 return random_art_bias_constitution(o_ptr);
120 return random_art_bias_charisma(o_ptr);
126 static bool random_art_bias_decrease_mana(object_type *o_ptr)
128 if (((o_ptr->artifact_bias != BIAS_MAGE) && (o_ptr->artifact_bias != BIAS_PRIESTLY)) || (o_ptr->tval != TV_SOFT_ARMOR) || (o_ptr->sval != SV_ROBE)
129 || o_ptr->art_flags.has(TR_DEC_MANA) || !one_in_(3))
132 o_ptr->art_flags.set(TR_DEC_MANA);
137 * @brief ランダムアーティファクト生成中、対象のオブジェクトにpval能力を付加する。/ Add one pval on generation of randam artifact.
138 * @details 優先的に付加されるpvalがランダムアーティファクトバイアスに依存して存在する。
139 * 原則的候補は腕力、知力、賢さ、器用さ、耐久、魅力、探索、隠密、赤外線視力、加速。武器のみ採掘、追加攻撃も候補に入る。
140 * @attention オブジェクトのtval、svalに依存したハードコーディング処理がある。
141 * @param o_ptr 対象のオブジェクト構造体ポインタ
143 void random_plus(object_type *o_ptr)
145 if (switch_random_art_bias(o_ptr) || random_art_bias_decrease_mana(o_ptr))
148 int this_type = o_ptr->is_weapon_ammo() ? 23 : 19;
149 switch (randint1(this_type)) {
152 o_ptr->art_flags.set(TR_STR);
153 if (!o_ptr->artifact_bias && !one_in_(13))
154 o_ptr->artifact_bias = BIAS_STR;
155 else if (!o_ptr->artifact_bias && one_in_(7))
156 o_ptr->artifact_bias = BIAS_WARRIOR;
161 o_ptr->art_flags.set(TR_INT);
162 if (!o_ptr->artifact_bias && !one_in_(13))
163 o_ptr->artifact_bias = BIAS_INT;
164 else if (!o_ptr->artifact_bias && one_in_(7))
165 o_ptr->artifact_bias = BIAS_MAGE;
170 o_ptr->art_flags.set(TR_WIS);
171 if (!o_ptr->artifact_bias && !one_in_(13))
172 o_ptr->artifact_bias = BIAS_WIS;
173 else if (!o_ptr->artifact_bias && one_in_(7))
174 o_ptr->artifact_bias = BIAS_PRIESTLY;
179 o_ptr->art_flags.set(TR_DEX);
180 if (!o_ptr->artifact_bias && !one_in_(13))
181 o_ptr->artifact_bias = BIAS_DEX;
182 else if (!o_ptr->artifact_bias && one_in_(7))
183 o_ptr->artifact_bias = BIAS_ROGUE;
188 o_ptr->art_flags.set(TR_CON);
189 if (!o_ptr->artifact_bias && !one_in_(13))
190 o_ptr->artifact_bias = BIAS_CON;
191 else if (!o_ptr->artifact_bias && one_in_(9))
192 o_ptr->artifact_bias = BIAS_RANGER;
197 o_ptr->art_flags.set(TR_CHR);
198 if (!o_ptr->artifact_bias && !one_in_(13))
199 o_ptr->artifact_bias = BIAS_CHR;
204 o_ptr->art_flags.set(TR_STEALTH);
205 if (!o_ptr->artifact_bias && one_in_(3))
206 o_ptr->artifact_bias = BIAS_ROGUE;
211 o_ptr->art_flags.set(TR_SEARCH);
212 if (!o_ptr->artifact_bias && one_in_(9))
213 o_ptr->artifact_bias = BIAS_RANGER;
218 o_ptr->art_flags.set(TR_INFRA);
221 o_ptr->art_flags.set(TR_SPEED);
222 if (!o_ptr->artifact_bias && one_in_(11))
223 o_ptr->artifact_bias = BIAS_ROGUE;
228 o_ptr->art_flags.set(TR_TUNNEL);
232 if (o_ptr->tval == TV_BOW) {
237 o_ptr->art_flags.set(TR_BLOWS);
238 if (!o_ptr->artifact_bias && one_in_(11))
239 o_ptr->artifact_bias = BIAS_WARRIOR;