1 #include "object/object-value-calc.h"
2 #include "artifact/artifact-info.h"
3 #include "object-enchant/object-ego.h"
4 #include "object-enchant/tr-types.h"
5 #include "object-enchant/trc-types.h"
6 #include "object-hook/hook-checker.h"
7 #include "object-hook/hook-enchant.h"
8 #include "object/object-flags.h"
9 #include "object/object-kind.h"
10 #include "system/artifact-type-definition.h"
11 #include "util/bit-flags-calculator.h"
14 * @brief オブジェクトのフラグ類から価格を算出する /
15 * Return the value of the flags the object has...
16 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
17 * @param plusses フラグに与える価格の基本重み
18 * @return オブジェクトのフラグ価格
20 PRICE flag_cost(player_type *player_ptr, object_type *o_ptr, int plusses)
23 BIT_FLAGS flgs[TR_FLAG_SIZE];
24 object_kind *k_ptr = &k_info[o_ptr->k_idx];
25 object_flags(player_ptr, o_ptr, flgs);
28 * Exclude fixed flags of the base item.
29 * pval bonuses of base item will be treated later.
31 for (int i = 0; i < TR_FLAG_SIZE; i++)
32 flgs[i] &= ~(k_ptr->flags[i]);
34 if (object_is_fixed_artifact(o_ptr)) {
35 artifact_type *a_ptr = &a_info[o_ptr->name1];
37 for (int i = 0; i < TR_FLAG_SIZE; i++)
38 flgs[i] &= ~(a_ptr->flags[i]);
39 } else if (object_is_ego(o_ptr)) {
40 ego_item_type *e_ptr = &e_info[o_ptr->name2];
42 for (int i = 0; i < TR_FLAG_SIZE; i++)
43 flgs[i] &= ~(e_ptr->flags[i]);
47 * Calucurate values of remaining flags
49 if (has_flag(flgs, TR_STR))
50 total += (1500 * plusses);
51 if (has_flag(flgs, TR_INT))
52 total += (1500 * plusses);
53 if (has_flag(flgs, TR_WIS))
54 total += (1500 * plusses);
55 if (has_flag(flgs, TR_DEX))
56 total += (1500 * plusses);
57 if (has_flag(flgs, TR_CON))
58 total += (1500 * plusses);
59 if (has_flag(flgs, TR_CHR))
60 total += (750 * plusses);
61 if (has_flag(flgs, TR_MAGIC_MASTERY))
62 total += (600 * plusses);
63 if (has_flag(flgs, TR_STEALTH))
64 total += (250 * plusses);
65 if (has_flag(flgs, TR_SEARCH))
66 total += (100 * plusses);
67 if (has_flag(flgs, TR_INFRA))
68 total += (150 * plusses);
69 if (has_flag(flgs, TR_TUNNEL))
70 total += (175 * plusses);
71 if ((has_flag(flgs, TR_SPEED)) && (plusses > 0))
72 total += (10000 + (2500 * plusses));
73 if ((has_flag(flgs, TR_BLOWS)) && (plusses > 0))
74 total += (10000 + (2500 * plusses));
78 if (has_flag(flgs, TR_CHAOTIC)) {
82 if (has_flag(flgs, TR_VAMPIRIC)) {
86 if (has_flag(flgs, TR_FORCE_WEAPON)) {
90 if (has_flag(flgs, TR_KILL_ANIMAL)) {
93 } else if (has_flag(flgs, TR_SLAY_ANIMAL)) {
97 if (has_flag(flgs, TR_KILL_EVIL)) {
100 } else if (has_flag(flgs, TR_SLAY_EVIL)) {
104 if (has_flag(flgs, TR_KILL_HUMAN)) {
107 } else if (has_flag(flgs, TR_SLAY_HUMAN)) {
111 if (has_flag(flgs, TR_KILL_UNDEAD)) {
114 } else if (has_flag(flgs, TR_SLAY_UNDEAD)) {
118 if (has_flag(flgs, TR_KILL_DEMON)) {
121 } else if (has_flag(flgs, TR_SLAY_DEMON)) {
125 if (has_flag(flgs, TR_KILL_ORC)) {
128 } else if (has_flag(flgs, TR_SLAY_ORC)) {
132 if (has_flag(flgs, TR_KILL_TROLL)) {
135 } else if (has_flag(flgs, TR_SLAY_TROLL)) {
139 if (has_flag(flgs, TR_KILL_GIANT)) {
142 } else if (has_flag(flgs, TR_SLAY_GIANT)) {
146 if (has_flag(flgs, TR_KILL_DRAGON)) {
149 } else if (has_flag(flgs, TR_SLAY_DRAGON)) {
154 if (has_flag(flgs, TR_VORPAL)) {
158 if (has_flag(flgs, TR_IMPACT)) {
162 if (has_flag(flgs, TR_BRAND_POIS)) {
166 if (has_flag(flgs, TR_BRAND_ACID)) {
170 if (has_flag(flgs, TR_BRAND_ELEC)) {
174 if (has_flag(flgs, TR_BRAND_FIRE)) {
178 if (has_flag(flgs, TR_BRAND_COLD)) {
182 total += (tmp_cost * count);
184 if (has_flag(flgs, TR_SUST_STR))
186 if (has_flag(flgs, TR_SUST_INT))
188 if (has_flag(flgs, TR_SUST_WIS))
190 if (has_flag(flgs, TR_SUST_DEX))
192 if (has_flag(flgs, TR_SUST_CON))
194 if (has_flag(flgs, TR_SUST_CHR))
196 if (has_flag(flgs, TR_RIDING))
198 if (has_flag(flgs, TR_EASY_SPELL))
200 if (has_flag(flgs, TR_THROW))
202 if (has_flag(flgs, TR_FREE_ACT))
204 if (has_flag(flgs, TR_HOLD_EXP))
209 if (has_flag(flgs, TR_IM_ACID)) {
213 if (has_flag(flgs, TR_IM_ELEC)) {
217 if (has_flag(flgs, TR_IM_FIRE)) {
221 if (has_flag(flgs, TR_IM_COLD)) {
225 if (has_flag(flgs, TR_REFLECT)) {
229 if (has_flag(flgs, TR_RES_ACID)) {
233 if (has_flag(flgs, TR_RES_ELEC)) {
237 if (has_flag(flgs, TR_RES_FIRE)) {
241 if (has_flag(flgs, TR_RES_COLD)) {
245 if (has_flag(flgs, TR_RES_POIS)) {
249 if (has_flag(flgs, TR_RES_FEAR)) {
253 if (has_flag(flgs, TR_RES_LITE)) {
257 if (has_flag(flgs, TR_RES_DARK)) {
261 if (has_flag(flgs, TR_RES_BLIND)) {
265 if (has_flag(flgs, TR_RES_CONF)) {
269 if (has_flag(flgs, TR_RES_SOUND)) {
273 if (has_flag(flgs, TR_RES_SHARDS)) {
277 if (has_flag(flgs, TR_RES_NETHER)) {
281 if (has_flag(flgs, TR_RES_NEXUS)) {
285 if (has_flag(flgs, TR_RES_CHAOS)) {
289 if (has_flag(flgs, TR_RES_DISEN)) {
293 total += (tmp_cost * count);
295 if (has_flag(flgs, TR_SH_FIRE))
297 if (has_flag(flgs, TR_SH_ELEC))
299 if (has_flag(flgs, TR_SH_COLD))
301 if (has_flag(flgs, TR_NO_TELE))
303 if (has_flag(flgs, TR_NO_MAGIC))
305 if (has_flag(flgs, TR_TY_CURSE))
307 if (has_flag(flgs, TR_HIDE_TYPE))
309 if (has_flag(flgs, TR_SHOW_MODS))
311 if (has_flag(flgs, TR_LEVITATION))
313 if (has_flag(flgs, TR_LITE_1))
315 if (has_flag(flgs, TR_LITE_2))
317 if (has_flag(flgs, TR_LITE_3))
319 if (has_flag(flgs, TR_LITE_M1))
321 if (has_flag(flgs, TR_LITE_M2))
323 if (has_flag(flgs, TR_LITE_M3))
325 if (has_flag(flgs, TR_SEE_INVIS))
327 if (has_flag(flgs, TR_TELEPATHY))
329 if (has_flag(flgs, TR_ESP_ANIMAL))
331 if (has_flag(flgs, TR_ESP_UNDEAD))
333 if (has_flag(flgs, TR_ESP_DEMON))
335 if (has_flag(flgs, TR_ESP_ORC))
337 if (has_flag(flgs, TR_ESP_TROLL))
339 if (has_flag(flgs, TR_ESP_GIANT))
341 if (has_flag(flgs, TR_ESP_DRAGON))
343 if (has_flag(flgs, TR_ESP_HUMAN))
345 if (has_flag(flgs, TR_ESP_EVIL))
347 if (has_flag(flgs, TR_ESP_GOOD))
349 if (has_flag(flgs, TR_ESP_NONLIVING))
351 if (has_flag(flgs, TR_ESP_UNIQUE))
353 if (has_flag(flgs, TR_SLOW_DIGEST))
355 if (has_flag(flgs, TR_REGEN))
357 if (has_flag(flgs, TR_WARNING))
359 if (has_flag(flgs, TR_DEC_MANA))
361 if (has_flag(flgs, TR_XTRA_MIGHT))
363 if (has_flag(flgs, TR_XTRA_SHOTS))
365 if (has_flag(flgs, TR_IGNORE_ACID))
367 if (has_flag(flgs, TR_IGNORE_ELEC))
369 if (has_flag(flgs, TR_IGNORE_FIRE))
371 if (has_flag(flgs, TR_IGNORE_COLD))
373 if (has_flag(flgs, TR_ACTIVATE))
375 if (has_flag(flgs, TR_DRAIN_EXP))
377 if (has_flag(flgs, TR_DRAIN_HP))
379 if (has_flag(flgs, TR_DRAIN_MANA))
381 if (has_flag(flgs, TR_CALL_ANIMAL))
383 if (has_flag(flgs, TR_CALL_DEMON))
385 if (has_flag(flgs, TR_CALL_DRAGON))
387 if (has_flag(flgs, TR_CALL_UNDEAD))
389 if (has_flag(flgs, TR_COWARDICE))
391 if (has_flag(flgs, TR_LOW_MELEE))
393 if (has_flag(flgs, TR_LOW_AC))
395 if (has_flag(flgs, TR_LOW_MAGIC))
397 if (has_flag(flgs, TR_FAST_DIGEST))
399 if (has_flag(flgs, TR_SLOW_REGEN))
401 if (has_flag(flgs, TR_TELEPORT)) {
402 if (object_is_cursed(o_ptr))
408 if (has_flag(flgs, TR_AGGRAVATE))
410 if (has_flag(flgs, TR_BLESSED))
412 if (o_ptr->curse_flags & TR_ADD_L_CURSE)
414 if (o_ptr->curse_flags & TR_ADD_H_CURSE)
416 if (o_ptr->curse_flags & TRC_CURSED)
418 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
420 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
423 /* Also, give some extra for activatable powers... */
424 if (o_ptr->art_name && (has_flag(o_ptr->art_flags, TR_ACTIVATE))) {
425 const activation_type *const act_ptr = find_activation_info(player_ptr, o_ptr);
427 total += act_ptr->value;