3 * @brief オブジェクトの実装 / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 #include "object-hook.h"
17 static void one_sustain(object_type *o_ptr);
20 static cptr const kaji_tips[5] =
23 "現在持っているエッセンスの一覧を表示する。",
24 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
25 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
26 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
27 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
29 "Display essences you have.",
30 "Extract essences from an item. The item become non magical.",
31 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
32 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
33 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
38 * @brief 対象のオブジェクトにランダムな能力維持を一つ付加する。/ Choose one random sustain
40 * @param o_ptr 対象のオブジェクト構造体ポインタ
43 static void one_sustain(object_type *o_ptr)
47 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
48 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
49 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
50 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
51 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
52 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
57 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
58 * @param o_idx 削除対象のオブジェクト構造体ポインタ
61 void excise_object_idx(int o_idx)
65 s16b this_o_idx, next_o_idx = 0;
71 j_ptr = &o_list[o_idx];
74 if (j_ptr->held_m_idx)
79 m_ptr = &m_list[j_ptr->held_m_idx];
81 /* Scan all objects in the grid */
82 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
87 o_ptr = &o_list[this_o_idx];
89 /* Acquire next object */
90 next_o_idx = o_ptr->next_o_idx;
93 if (this_o_idx == o_idx)
98 /* Remove from list */
99 m_ptr->hold_o_idx = next_o_idx;
107 /* Previous object */
108 k_ptr = &o_list[prev_o_idx];
110 /* Remove from list */
111 k_ptr->next_o_idx = next_o_idx;
114 /* Forget next pointer */
115 o_ptr->next_o_idx = 0;
121 /* Save prev_o_idx */
122 prev_o_idx = this_o_idx;
137 /* Scan all objects in the grid */
138 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
143 o_ptr = &o_list[this_o_idx];
145 /* Acquire next object */
146 next_o_idx = o_ptr->next_o_idx;
149 if (this_o_idx == o_idx)
154 /* Remove from list */
155 c_ptr->o_idx = next_o_idx;
163 /* Previous object */
164 k_ptr = &o_list[prev_o_idx];
166 /* Remove from list */
167 k_ptr->next_o_idx = next_o_idx;
170 /* Forget next pointer */
171 o_ptr->next_o_idx = 0;
177 /* Save prev_o_idx */
178 prev_o_idx = this_o_idx;
184 * @brief オブジェクトを削除する /
185 * Delete a dungeon object
186 * @param o_idx 削除対象のオブジェクト構造体ポインタ
189 * Handle "stacks" of objects correctly.
191 void delete_object_idx(int o_idx)
196 excise_object_idx(o_idx);
199 j_ptr = &o_list[o_idx];
202 if (!(j_ptr->held_m_idx))
214 /* Wipe the object */
223 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
224 * Delete a dungeon object
225 * @param y 削除したフロアマスのY座標
226 * @param x 削除したフロアマスのX座標
229 void delete_object(int y, int x)
233 s16b this_o_idx, next_o_idx = 0;
236 /* Refuse "illegal" locations */
237 if (!in_bounds(y, x)) return;
243 /* Scan all objects in the grid */
244 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
249 o_ptr = &o_list[this_o_idx];
251 /* Acquire next object */
252 next_o_idx = o_ptr->next_o_idx;
254 /* Wipe the object */
261 /* Objects are gone */
270 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
271 * Move an object from index i1 to index i2 in the object list
272 * @param i1 整理したい配列の始点
273 * @param i2 整理したい配列の終点
276 static void compact_objects_aux(IDX i1, IDX i2)
283 if (i1 == i2) return;
287 for (i = 1; i < o_max; i++)
292 /* Skip "dead" objects */
293 if (!o_ptr->k_idx) continue;
295 /* Repair "next" pointers */
296 if (o_ptr->next_o_idx == i1)
299 o_ptr->next_o_idx = i2;
309 if (o_ptr->held_m_idx)
313 /* Acquire monster */
314 m_ptr = &m_list[o_ptr->held_m_idx];
317 if (m_ptr->hold_o_idx == i1)
320 m_ptr->hold_o_idx = i2;
329 /* Acquire location */
337 if (c_ptr->o_idx == i1)
346 o_list[i2] = o_list[i1];
354 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
355 * Compact and Reorder the object list.
356 * @param size 最低でも減らしたいオブジェクト数の水準
360 * This function can be very dangerous, use with caution!\n
362 * When actually "compacting" objects, we base the saving throw on a\n
363 * combination of object level, distance from player, and current\n
366 * After "compacting" (if needed), we "reorder" the objects into a more\n
367 * compact order, and we reset the allocation info, and the "live" array.\n
369 void compact_objects(int size)
373 int cur_lev, cur_dis, chance;
381 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
384 p_ptr->redraw |= (PR_MAP);
387 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
391 /* Compact at least 'size' objects */
392 for (num = 0, cnt = 1; num < size; cnt++)
394 /* Get more vicious each iteration */
397 /* Get closer each iteration */
398 cur_dis = 5 * (20 - cnt);
400 /* Examine the objects */
401 for (i = 1; i < o_max; i++)
405 /* Skip dead objects */
406 if (!o_ptr->k_idx) continue;
408 /* Hack -- High level objects start out "immune" */
409 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
412 if (o_ptr->held_m_idx)
416 /* Acquire monster */
417 m_ptr = &m_list[o_ptr->held_m_idx];
419 /* Get the location */
423 /* Monsters protect their objects */
424 if (randint0(100) < 90) continue;
430 /* Get the location */
435 /* Nearby objects start out "immune" */
436 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
441 /* Hack -- only compact artifacts in emergencies */
442 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
443 (cnt < 1000)) chance = 100;
445 /* Apply the saving throw */
446 if (randint0(100) < chance) continue;
448 /* Delete the object */
449 delete_object_idx(i);
457 /* Excise dead objects (backwards!) */
458 for (i = o_max - 1; i >= 1; i--)
462 /* Skip real objects */
463 if (o_ptr->k_idx) continue;
465 /* Move last object into open hole */
466 compact_objects_aux(o_max - 1, i);
468 /* Compress "o_max" */
475 * @brief グローバルオブジェクト配列を初期化する /
476 * Delete all the items when player leaves the level
477 * @note we do NOT visually reflect these (irrelevant) changes
479 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
480 * and the "m_ptr->next_o_idx" field for every monster, since
481 * we know we are clearing every object. Technically, we only
482 * clear those fields for grids/monsters containing objects,
483 * and we clear it once for every such object.
486 void wipe_o_list(void)
490 /* Delete the existing objects */
491 for (i = 1; i < o_max; i++)
493 object_type *o_ptr = &o_list[i];
495 /* Skip dead objects */
496 if (!o_ptr->k_idx) continue;
498 /* Mega-Hack -- preserve artifacts */
499 if (!character_dungeon || preserve_mode)
501 /* Hack -- Preserve unknown artifacts */
502 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
504 /* Mega-Hack -- Preserve the artifact */
505 a_info[o_ptr->name1].cur_num = 0;
510 if (o_ptr->held_m_idx)
515 m_ptr = &m_list[o_ptr->held_m_idx];
517 /* Hack -- see above */
518 m_ptr->hold_o_idx = 0;
526 /* Access location */
533 /* Hack -- see above */
537 /* Wipe the object */
550 * @brief グローバルオブジェクト配列から空きを取得する /
551 * Acquires and returns the index of a "free" object.
552 * @return 開いているオブジェクト要素のID
554 * This routine should almost never fail, but in case it does,
555 * we must be sure to handle "failure" of this routine.
562 /* Initial allocation */
563 if (o_max < max_o_idx)
568 /* Expand object array */
574 /* Use this object */
579 /* Recycle dead objects */
580 for (i = 1; i < o_max; i++)
587 /* Skip live objects */
588 if (o_ptr->k_idx) continue;
593 /* Use this object */
598 /* Warn the player (except during dungeon creation) */
599 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
607 * @brief オブジェクト生成テーブルに生成制約を加える /
608 * Apply a "object restriction function" to the "object allocation table"
610 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
612 static errr get_obj_num_prep(void)
617 alloc_entry *table = alloc_kind_table;
619 /* Scan the allocation table */
620 for (i = 0; i < alloc_kind_size; i++)
622 /* Accept objects which pass the restriction, if any */
623 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
625 /* Accept this object */
626 table[i].prob2 = table[i].prob1;
629 /* Do not use this object */
632 /* Decline this object */
643 * @brief オブジェクト生成テーブルからアイテムを取得する /
644 * Choose an object kind that seems "appropriate" to the given level
646 * @return 選ばれたオブジェクトベースID
648 * This function uses the "prob2" field of the "object allocation table",\n
649 * and various local information, to calculate the "prob3" field of the\n
650 * same table, which is then used to choose an "appropriate" object, in\n
651 * a relatively efficient manner.\n
653 * It is (slightly) more likely to acquire an object of the given level\n
654 * than one of a lower level. This is done by choosing several objects\n
655 * appropriate to the given level and keeping the "hardest" one.\n
657 * Note that if no objects are "appropriate", then this function will\n
658 * fail, and return zero, but this should *almost* never happen.\n
660 s16b get_obj_num(int level)
666 alloc_entry *table = alloc_kind_table;
668 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
671 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
673 /* Occasional "boost" */
674 if (one_in_(GREAT_OBJ))
676 /* What a bizarre calculation */
677 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
684 /* Process probabilities */
685 for (i = 0; i < alloc_kind_size; i++)
687 /* Objects are sorted by depth */
688 if (table[i].level > level) break;
693 /* Access the index */
694 k_idx = table[i].index;
696 /* Access the actual kind */
697 k_ptr = &k_info[k_idx];
699 /* Hack -- prevent embedded chests */
700 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
703 table[i].prob3 = table[i].prob2;
706 total += table[i].prob3;
709 /* No legal objects */
710 if (total <= 0) return (0);
714 value = randint0(total);
716 /* Find the object */
717 for (i = 0; i < alloc_kind_size; i++)
719 /* Found the entry */
720 if (value < table[i].prob3) break;
723 value = value - table[i].prob3;
730 /* Try for a "better" object once (50%) or twice (10%) */
737 value = randint0(total);
739 /* Find the object */
740 for (i = 0; i < alloc_kind_size; i++)
742 /* Found the entry */
743 if (value < table[i].prob3) break;
746 value = value - table[i].prob3;
749 /* Keep the "best" one */
750 if (table[i].level < table[j].level) i = j;
753 /* Try for a "better" object twice (10%) */
760 value = randint0(total);
762 /* Find the object */
763 for (i = 0; i < alloc_kind_size; i++)
765 /* Found the entry */
766 if (value < table[i].prob3) break;
769 value = value - table[i].prob3;
772 /* Keep the "best" one */
773 if (table[i].level < table[j].level) i = j;
778 return (table[i].index);
783 * @brief オブジェクトを鑑定済にする /
784 * Known is true when the "attributes" of an object are "known".
785 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
787 * These include tohit, todam, toac, cost, and pval (charges).\n
789 * Note that "knowing" an object gives you everything that an "awareness"\n
790 * gives you, and much more. In fact, the player is always "aware" of any\n
791 * item of which he has full "knowledge".\n
793 * But having full knowledge of, say, one "wand of wonder", does not, by\n
794 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
795 * It happens that most "identify" routines (including "buying from a shop")\n
796 * will make the player "aware" of the object as well as fully "know" it.\n
798 * This routine also removes any inscriptions generated by "feelings".\n
800 void object_known(object_type *o_ptr)
802 /* Remove "default inscriptions" */
803 o_ptr->feeling = FEEL_NONE;
805 /* Clear the "Felt" info */
806 o_ptr->ident &= ~(IDENT_SENSE);
808 /* Clear the "Empty" info */
809 o_ptr->ident &= ~(IDENT_EMPTY);
811 /* Now we know about the item */
812 o_ptr->ident |= (IDENT_KNOWN);
816 * @brief オブジェクトを*鑑定*済にする /
817 * The player is now aware of the effects of the given object.
818 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
821 void object_aware(object_type *o_ptr)
823 bool mihanmei = !object_is_aware(o_ptr);
825 /* Fully aware of the effects */
826 k_info[o_ptr->k_idx].aware = TRUE;
828 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
829 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
833 char o_name[MAX_NLEN];
836 object_copy(q_ptr, o_ptr);
839 object_desc(o_name, q_ptr, OD_NAME_ONLY);
841 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
847 * @brief オブジェクトを試行済にする /
848 * Something has been "sampled"
849 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
852 void object_tried(object_type *o_ptr)
854 /* Mark it as tried (even if "aware") */
855 k_info[o_ptr->k_idx].tried = TRUE;
860 * @brief 未鑑定なベースアイテムの基本価格を返す /
861 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
862 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
863 * @return オブジェクトの未鑑定価格
865 static s32b object_value_base(object_type *o_ptr)
867 /* Aware item -- use template cost */
868 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
870 /* Analyze the type */
875 case TV_FOOD: return (5L);
877 /* Un-aware Potions */
878 case TV_POTION: return (20L);
880 /* Un-aware Scrolls */
881 case TV_SCROLL: return (20L);
883 /* Un-aware Staffs */
884 case TV_STAFF: return (70L);
887 case TV_WAND: return (50L);
890 case TV_ROD: return (90L);
893 case TV_RING: return (45L);
895 /* Un-aware Amulets */
896 case TV_AMULET: return (45L);
898 /* Figurines, relative to monster level */
901 int level = r_info[o_ptr->pval].level;
902 if (level < 20) return level*50L;
903 else if (level < 30) return 1000+(level-20)*150L;
904 else if (level < 40) return 2500+(level-30)*350L;
905 else if (level < 50) return 6000+(level-40)*800L;
906 else return 14000+(level-50)*2000L;
910 if (!o_ptr->pval) return 1000L;
911 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
914 /* Paranoia -- Oops */
920 * @brief オブジェクトのフラグ類から価格を算出する /
921 * Return the value of the flags the object has...
922 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
923 * @param plusses フラグに与える価格の基本重み
924 * @return オブジェクトのフラグ価格
926 s32b flag_cost(object_type *o_ptr, int plusses)
929 u32b flgs[TR_FLAG_SIZE];
933 object_kind *k_ptr = &k_info[o_ptr->k_idx];
935 object_flags(o_ptr, flgs);
938 * Exclude fixed flags of the base item.
939 * pval bonuses of base item will be treated later.
941 for (i = 0; i < TR_FLAG_SIZE; i++)
942 flgs[i] &= ~(k_ptr->flags[i]);
944 /* Exclude fixed flags of the fixed artifact. */
945 if (object_is_fixed_artifact(o_ptr))
947 artifact_type *a_ptr = &a_info[o_ptr->name1];
949 for (i = 0; i < TR_FLAG_SIZE; i++)
950 flgs[i] &= ~(a_ptr->flags[i]);
953 /* Exclude fixed flags of the ego-item. */
954 else if (object_is_ego(o_ptr))
956 ego_item_type *e_ptr = &e_info[o_ptr->name2];
958 for (i = 0; i < TR_FLAG_SIZE; i++)
959 flgs[i] &= ~(e_ptr->flags[i]);
964 * Calucurate values of remaining flags
966 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
967 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
968 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
969 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
970 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
971 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
972 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
973 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
974 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
975 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
976 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
977 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
978 total += (10000 + (2500 * plusses));
979 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
980 total += (10000 + (2500 * plusses));
984 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
985 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
986 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
987 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
988 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
989 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
990 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
991 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
992 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
993 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
994 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
995 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
996 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
997 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
998 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
999 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
1000 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
1001 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
1002 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
1003 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
1004 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
1006 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
1007 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
1008 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
1009 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
1010 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
1011 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
1012 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
1013 total += (tmp_cost * count);
1015 if (have_flag(flgs, TR_SUST_STR)) total += 850;
1016 if (have_flag(flgs, TR_SUST_INT)) total += 850;
1017 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
1018 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
1019 if (have_flag(flgs, TR_SUST_CON)) total += 850;
1020 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
1021 if (have_flag(flgs, TR_RIDING)) total += 0;
1022 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1023 if (have_flag(flgs, TR_THROW)) total += 5000;
1024 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1025 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1029 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1030 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1031 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1032 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1033 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1034 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1035 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1036 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1037 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1038 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1039 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1040 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1041 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1042 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1043 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1044 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1045 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1046 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1047 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1048 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1049 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1050 total += (tmp_cost * count);
1052 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1053 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1054 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1055 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1056 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1057 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1058 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1059 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1060 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1061 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1062 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1063 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1064 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1065 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1066 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1067 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1068 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1069 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1070 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1071 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1072 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1073 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1074 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1075 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1076 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1077 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1078 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1079 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1080 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1081 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1082 if (have_flag(flgs, TR_REGEN)) total += 2500;
1083 if (have_flag(flgs, TR_WARNING)) total += 2000;
1084 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1085 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1086 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1087 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1088 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1089 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1090 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1091 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1092 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1093 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1094 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1095 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1096 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1097 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1098 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1099 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1100 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1101 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1102 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1103 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1104 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1105 if (have_flag(flgs, TR_TELEPORT))
1107 if (object_is_cursed(o_ptr))
1112 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1113 if (have_flag(flgs, TR_BLESSED)) total += 750;
1114 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1115 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1116 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1117 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1118 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1120 /* Also, give some extra for activatable powers... */
1121 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1123 const activation_type* const act_ptr = find_activation_info(o_ptr);
1125 total += act_ptr->value;
1134 * @brief オブジェクトの真の価格を算出する /
1135 * Return the value of the flags the object has...
1136 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1137 * @return オブジェクトの本価格
1139 * Return the "real" price of a "known" item, not including discounts\n
1141 * Wand and staffs get cost for each charge\n
1143 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1145 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1147 * Missiles are only worth 5 gold per bonus point, since they\n
1148 * usually appear in groups of 20, and we want the player to get\n
1149 * the same amount of cash for any "equivalent" item. Note that\n
1150 * missiles never have any of the "pval" flags, and in fact, they\n
1151 * only have a few of the available flags, primarily of the "slay"\n
1152 * and "brand" and "ignore" variety.\n
1154 * Armor with a negative armor bonus is worthless.\n
1155 * Weapons with negative hit+damage bonuses are worthless.\n
1157 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1159 s32b object_value_real(object_type *o_ptr)
1163 u32b flgs[TR_FLAG_SIZE];
1165 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1168 /* Hack -- "worthless" items */
1169 if (!k_info[o_ptr->k_idx].cost) return (0L);
1172 value = k_info[o_ptr->k_idx].cost;
1174 /* Extract some flags */
1175 object_flags(o_ptr, flgs);
1178 if (object_is_fixed_artifact(o_ptr))
1180 artifact_type *a_ptr = &a_info[o_ptr->name1];
1182 /* Hack -- "worthless" artifacts */
1183 if (!a_ptr->cost) return (0L);
1185 /* Hack -- Use the artifact cost instead */
1186 value = a_ptr->cost;
1187 value += flag_cost(o_ptr, o_ptr->pval);
1189 /* Don't add pval bonuses etc. */
1194 else if (object_is_ego(o_ptr))
1196 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1198 /* Hack -- "worthless" ego-items */
1199 if (!e_ptr->cost) return (0L);
1201 /* Hack -- Reward the ego-item with a bonus */
1202 value += e_ptr->cost;
1203 value += flag_cost(o_ptr, o_ptr->pval);
1211 for (i = 0; i < TR_FLAG_SIZE; i++)
1212 if (o_ptr->art_flags[i]) flag = TRUE;
1214 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1217 /* Analyze pval bonus for normal object */
1218 switch (o_ptr->tval)
1241 if (!o_ptr->pval) break;
1243 /* Hack -- Negative "pval" is always bad */
1244 if (o_ptr->pval < 0) return (0L);
1246 /* Give credit for stat bonuses */
1247 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1248 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1249 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1250 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1251 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1252 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1254 /* Give credit for stealth and searching */
1255 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1256 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1257 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1259 /* Give credit for infra-vision and tunneling */
1260 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1261 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1263 /* Give credit for extra attacks */
1264 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1266 /* Give credit for speed bonus */
1267 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1273 /* Analyze the item */
1274 switch (o_ptr->tval)
1279 /* Pay extra for charges, depending on standard number of
1280 * charges. Handle new-style wands correctly. -LM-
1282 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1289 /* Pay extra for charges, depending on standard number of
1292 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1302 /* Hack -- negative bonuses are bad */
1303 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1305 /* Give credit for bonuses */
1306 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1323 /* Hack -- negative armor bonus */
1324 if (o_ptr->to_a < 0) return (0L);
1326 /* Give credit for bonuses */
1327 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1340 /* Hack -- negative hit/damage bonuses */
1341 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1343 /* Factor in the bonuses */
1344 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1346 /* Hack -- Factor in extra damage dice and sides */
1347 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1348 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1359 /* Hack -- negative hit/damage bonuses */
1360 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1362 /* Factor in the bonuses */
1363 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1365 /* Hack -- Factor in extra damage dice and sides */
1366 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1367 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1373 /* Figurines, relative to monster level */
1376 int level = r_info[o_ptr->pval].level;
1377 if (level < 20) value = level*50L;
1378 else if (level < 30) value = 1000+(level-20)*150L;
1379 else if (level < 40) value = 2500+(level-30)*350L;
1380 else if (level < 50) value = 6000+(level-40)*800L;
1381 else value = 14000+(level-50)*2000L;
1387 if (!o_ptr->pval) value = 1000L;
1388 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1394 if (!o_ptr->pval) value = 0L;
1399 /* Worthless object */
1400 if (value < 0) return 0L;
1402 /* Return the value */
1408 * @brief オブジェクト価格算出のメインルーチン /
1409 * Return the price of an item including plusses (and charges)
1410 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1411 * @return オブジェクトの判明している現価格
1413 * This function returns the "value" of the given item (qty one)\n
1415 * Never notice "unknown" bonuses or properties, including "curses",\n
1416 * since that would give the player information he did not have.\n
1418 * Note that discounted items stay discounted forever, even if\n
1419 * the discount is "forgotten" by the player via memory loss.\n
1421 s32b object_value(object_type *o_ptr)
1426 /* Unknown items -- acquire a base value */
1427 if (object_is_known(o_ptr))
1429 /* Broken items -- worthless */
1430 if (object_is_broken(o_ptr)) return (0L);
1432 /* Cursed items -- worthless */
1433 if (object_is_cursed(o_ptr)) return (0L);
1435 /* Real value (see above) */
1436 value = object_value_real(o_ptr);
1439 /* Known items -- acquire the actual value */
1442 /* Hack -- Felt broken items */
1443 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1445 /* Hack -- Felt cursed items */
1446 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1448 /* Base value (see above) */
1449 value = object_value_base(o_ptr);
1453 /* Apply discount (if any) */
1454 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1457 /* Return the final value */
1464 * @brief 破壊可能なアイテムかを返す /
1465 * Determines whether an object can be destroyed, and makes fake inscription.
1466 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1467 * @return オブジェクトが破壊可能ならばTRUEを返す
1469 bool can_player_destroy_object(object_type *o_ptr)
1471 /* Artifacts cannot be destroyed */
1472 if (!object_is_artifact(o_ptr)) return TRUE;
1474 /* If object is unidentified, makes fake inscription */
1475 if (!object_is_known(o_ptr))
1477 byte feel = FEEL_SPECIAL;
1479 /* Hack -- Handle icky artifacts */
1480 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1482 /* Hack -- inscribe the artifact */
1483 o_ptr->feeling = feel;
1485 /* We have "felt" it (again) */
1486 o_ptr->ident |= (IDENT_SENSE);
1488 /* Combine the pack */
1489 p_ptr->notice |= (PN_COMBINE);
1492 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1498 /* Identified artifact -- Nothing to do */
1504 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1505 * Distribute charges of rods or wands.
1506 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1507 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1508 * @param amt 分割したい回数量 number of items that are transfered
1511 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1512 * charges need to be allocated between the two stacks. If all the items\n
1513 * are being dropped, it makes for a neater message to leave the original\n
1514 * stack's pval alone. -LM-\n
1516 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1518 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1520 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1521 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1523 /* Hack -- Rods also need to have their timeouts distributed. The
1524 * dropped stack will accept all time remaining to charge up to its
1527 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1529 if (q_ptr->pval > o_ptr->timeout)
1530 q_ptr->timeout = o_ptr->timeout;
1532 q_ptr->timeout = q_ptr->pval;
1534 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1540 * @brief 魔法棒やロッドの使用回数を減らす /
1541 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1542 * @param amt 減らしたい回数量 number of items that are transfered
1545 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1546 * charges of the stack needs to be reduced, unless all the items are\n
1547 * being destroyed. -LM-\n
1549 void reduce_charges(object_type *o_ptr, int amt)
1551 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1552 (amt < o_ptr->number))
1554 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1559 * Determine if an item can "absorb" a second item
1561 * See "object_absorb()" for the actual "absorption" code.
1563 * If permitted, we allow staffs (if they are known to have equal charges
1564 * and both are either known or confirmed empty) and wands (if both are
1565 * either known or confirmed empty) and rods (in all cases) to combine.
1566 * Staffs will unstack (if necessary) when they are used, but wands and
1567 * rods will only unstack if one is dropped. -LM-
1569 * If permitted, we allow weapons/armor to stack, if fully "known".
1571 * Missiles will combine if both stacks have the same "known" status.
1572 * This is done to make unidentified stacks of missiles useful.
1574 * Food, potions, scrolls, and "easy know" items always stack.
1576 * Chests, and activatable items, never stack (for various reasons).
1580 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1582 #define MAX_STACK_SIZE 99
1586 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1587 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1588 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1589 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1590 * @return 重ね合わせ可能なアイテム数
1592 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1596 /* Default maximum number of stack */
1597 int max_num = MAX_STACK_SIZE;
1599 /* Require identical object types */
1600 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1603 /* Analyze the items */
1604 switch (o_ptr->tval)
1606 /* Chests and Statues*/
1617 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1618 if (o_ptr->pval != j_ptr->pval) return 0;
1622 /* Figurines and Corpses*/
1627 if (o_ptr->pval != j_ptr->pval) return 0;
1633 /* Food and Potions and Scrolls */
1645 /* Require either knowledge or known empty for both staffs. */
1646 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1647 !object_is_known(o_ptr)) ||
1648 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1649 !object_is_known(j_ptr))) return 0;
1651 /* Require identical charges, since staffs are bulky. */
1652 if (o_ptr->pval != j_ptr->pval) return 0;
1661 /* Require either knowledge or known empty for both wands. */
1662 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1663 !object_is_known(o_ptr)) ||
1664 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1665 !object_is_known(j_ptr))) return 0;
1667 /* Wand charges combine in O&ZAngband. */
1673 /* Staffs and Wands and Rods */
1676 /* Prevent overflaw of timeout */
1677 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1683 /* Weapons and Armor */
1699 /* Rings, Amulets, Lites */
1705 /* Require full knowledge of both items */
1706 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1716 /* Require identical knowledge of both items */
1717 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1718 if (o_ptr->feeling != j_ptr->feeling) return 0;
1720 /* Require identical "bonuses" */
1721 if (o_ptr->to_h != j_ptr->to_h) return 0;
1722 if (o_ptr->to_d != j_ptr->to_d) return 0;
1723 if (o_ptr->to_a != j_ptr->to_a) return 0;
1725 /* Require identical "pval" code */
1726 if (o_ptr->pval != j_ptr->pval) return 0;
1728 /* Artifacts never stack */
1729 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1731 /* Require identical "ego-item" names */
1732 if (o_ptr->name2 != j_ptr->name2) return 0;
1734 /* Require identical added essence */
1735 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1736 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1738 /* Hack -- Never stack "powerful" items */
1739 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1741 /* Hack -- Never stack recharging items */
1742 if (o_ptr->timeout || j_ptr->timeout) return 0;
1744 /* Require identical "values" */
1745 if (o_ptr->ac != j_ptr->ac) return 0;
1746 if (o_ptr->dd != j_ptr->dd) return 0;
1747 if (o_ptr->ds != j_ptr->ds) return 0;
1756 /* Require knowledge */
1757 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1765 /* Hack -- Identical art_flags! */
1766 for (i = 0; i < TR_FLAG_SIZE; i++)
1767 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1769 /* Hack -- Require identical "cursed" status */
1770 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1772 /* Hack -- Require identical "broken" status */
1773 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1776 /* Hack -- require semi-matching "inscriptions" */
1777 if (o_ptr->inscription && j_ptr->inscription &&
1778 (o_ptr->inscription != j_ptr->inscription))
1781 /* Hack -- normally require matching "inscriptions" */
1782 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1784 /* Hack -- normally require matching "discounts" */
1785 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1788 /* They match, so they must be similar */
1793 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1794 * Determine if an item can absorb a second item.
1795 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1796 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1797 * @return 重ね合わせ可能ならばTRUEを返す。
1799 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1801 int total = o_ptr->number + j_ptr->number;
1804 /* Are these objects similar? */
1805 max_num = object_similar_part(o_ptr, j_ptr);
1807 /* Return if not similar */
1808 if (!max_num) return FALSE;
1810 /* Maximal "stacking" limit */
1811 if (total > max_num) return (0);
1814 /* They match, so they must be similar */
1820 * @brief 両オブジェクトをスロットに重ね合わせる。
1821 * Allow one item to "absorb" another, assuming they are similar
1822 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1823 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1826 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1828 int max_num = object_similar_part(o_ptr, j_ptr);
1829 int total = o_ptr->number + j_ptr->number;
1830 int diff = (total > max_num) ? total - max_num : 0;
1832 /* Combine quantity, lose excess items */
1833 o_ptr->number = (total > max_num) ? max_num : total;
1835 /* Hack -- blend "known" status */
1836 if (object_is_known(j_ptr)) object_known(o_ptr);
1838 /* Hack -- clear "storebought" if only one has it */
1839 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1840 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1842 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1843 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1846 /* Hack -- blend "mental" status */
1847 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1849 /* Hack -- blend "inscriptions" */
1850 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1852 /* Hack -- blend "feelings" */
1853 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1855 /* Hack -- could average discounts XXX XXX XXX */
1856 /* Hack -- save largest discount XXX XXX XXX */
1857 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1859 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1860 if (o_ptr->tval == TV_ROD)
1862 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1863 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1866 /* Hack -- if wands are stacking, combine the charges. -LM- */
1867 if (o_ptr->tval == TV_WAND)
1869 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1875 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1876 * Find the index of the object_kind with the given tval and sval
1877 * @param tval 検索したいベースアイテムのtval
1878 * @param sval 検索したいベースアイテムのsval
1881 IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
1888 for (k = 1; k < max_k_idx; k++)
1890 object_kind *k_ptr = &k_info[k];
1892 /* Require correct tval */
1893 if (k_ptr->tval != tval) continue;
1896 if (k_ptr->sval == sval) return (k);
1898 /* Ignore illegal items */
1899 if (sval != SV_ANY) continue;
1901 /* Apply the randomizer */
1902 if (!one_in_(++num)) continue;
1904 /* Use this value */
1908 /* Return this choice */
1916 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1926 * @brief オブジェクトを初期化する
1927 * Wipe an object clean.
1928 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1931 void object_wipe(object_type *o_ptr)
1933 /* Wipe the structure */
1934 (void)WIPE(o_ptr, object_type);
1939 * @brief オブジェクトを複製する
1940 * Wipe an object clean.
1941 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1942 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1945 void object_copy(object_type *o_ptr, object_type *j_ptr)
1947 /* Copy the structure */
1948 (void)COPY(o_ptr, j_ptr, object_type);
1953 * @brief オブジェクト構造体にベースアイテムを作成する
1954 * Prepare an object based on an object kind.
1955 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1956 * @param k_idx 新たに作成したいベースアイテム情報のID
1959 void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
1961 object_kind *k_ptr = &k_info[k_idx];
1963 /* Clear the record */
1966 /* Save the kind index */
1967 o_ptr->k_idx = k_idx;
1969 /* Efficiency -- tval/sval */
1970 o_ptr->tval = k_ptr->tval;
1971 o_ptr->sval = k_ptr->sval;
1973 /* Default "pval" */
1974 o_ptr->pval = k_ptr->pval;
1976 /* Default number */
1979 /* Default weight */
1980 o_ptr->weight = k_ptr->weight;
1983 o_ptr->to_h = k_ptr->to_h;
1984 o_ptr->to_d = k_ptr->to_d;
1985 o_ptr->to_a = k_ptr->to_a;
1988 o_ptr->ac = k_ptr->ac;
1989 o_ptr->dd = k_ptr->dd;
1990 o_ptr->ds = k_ptr->ds;
1992 /* Default activation */
1993 if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx;
1995 /* Hack -- worthless items are always "broken" */
1996 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1998 /* Hack -- cursed items are always "cursed" */
1999 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
2000 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2001 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
2002 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
2003 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
2004 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
2009 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
2010 * Help determine an "enchantment bonus" for an object.
2011 * @param max ボーナス値の限度
2012 * @param level ボーナス値に加味する基準生成階
2013 * @return 算出されたボーナス値
2015 * To avoid floating point but still provide a smooth distribution of bonuses,\n
2016 * we simply round the results of division in such a way as to "average" the\n
2017 * correct floating point value.\n
2019 * This function has been changed. It uses "randnor()" to choose values from\n
2020 * a normal distribution, whose mean moves from zero towards the max as the\n
2021 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2022 * and whose values are forced to lie between zero and the max, inclusive.\n
2024 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2025 * rare to get the "full" enchantment on an object, even a deep levels.\n
2027 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2029 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2031 * N 0 1 2 3 4 5 6 7 8 9 10\n
2032 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2033 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2034 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2035 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2036 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2037 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2038 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2039 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2040 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2041 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2042 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2043 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2044 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2045 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2046 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2047 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2048 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2049 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2051 int m_bonus(int max, DEPTH level)
2053 int bonus, stand, extra, value;
2056 /* Paranoia -- enforce maximal "level" */
2057 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2060 /* The "bonus" moves towards the max */
2061 bonus = ((max * level) / MAX_DEPTH);
2063 /* Hack -- determine fraction of error */
2064 extra = ((max * level) % MAX_DEPTH);
2066 /* Hack -- simulate floating point computations */
2067 if (randint0(MAX_DEPTH) < extra) bonus++;
2070 /* The "stand" is equal to one quarter of the max */
2073 /* Hack -- determine fraction of error */
2076 /* Hack -- simulate floating point computations */
2077 if (randint0(4) < extra) stand++;
2080 /* Choose an "interesting" value */
2081 value = randnor(bonus, stand);
2083 /* Enforce the minimum value */
2084 if (value < 0) return (0);
2086 /* Enforce the maximum value */
2087 if (value > max) return (max);
2095 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2096 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2099 static void object_mention(object_type *o_ptr)
2101 char o_name[MAX_NLEN];
2103 object_aware(o_ptr);
2104 object_known(o_ptr);
2106 /* Mark the item as fully known */
2107 o_ptr->ident |= (IDENT_MENTAL);
2110 object_desc(o_name, o_ptr, 0);
2111 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2115 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2116 * Mega-Hack -- Attempt to create one of the "Special Objects"
2117 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2118 * @return 生成に成功したらTRUEを返す。
2120 * We are only called from "make_object()", and we assume that\n
2121 * "apply_magic()" is called immediately after we return.\n
2123 * Note -- see "make_artifact()" and "apply_magic()"\n
2125 static bool make_artifact_special(object_type *o_ptr)
2130 /*! @note 地上ではキャンセルする / No artifacts in the town */
2131 if (!dun_level) return (FALSE);
2133 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2134 if (get_obj_num_hook) return (FALSE);
2136 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2137 for (i = 0; i < max_a_idx; i++)
2139 artifact_type *a_ptr = &a_info[i];
2141 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2142 if (!a_ptr->name) continue;
2144 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2145 if (a_ptr->cur_num) continue;
2146 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2147 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2149 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2150 * XXX XXX Enforce minimum "depth" (loosely) */
2151 if (a_ptr->level > object_level)
2153 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2154 int d = (a_ptr->level - object_level) * 2;
2155 if (!one_in_(d)) continue;
2158 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2159 if (!one_in_(a_ptr->rarity)) continue;
2161 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2162 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2163 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2164 if (k_info[k_idx].level > object_level)
2166 int d = (k_info[k_idx].level - object_level) * 5;
2167 if (!one_in_(d)) continue;
2170 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2171 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2172 object_prep(o_ptr, k_idx);
2175 random_artifact_resistance(o_ptr, a_ptr);
2179 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2185 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2186 * Mega-Hack -- Attempt to create one of the "Special Objects"
2187 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2188 * @return 生成に成功したらTRUEを返す。
2190 * Attempt to change an object into an artifact\n
2191 * This routine should only be called by "apply_magic()"\n
2192 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2194 static bool make_artifact(object_type *o_ptr)
2199 /* No artifacts in the town */
2200 if (!dun_level) return (FALSE);
2202 /* Paranoia -- no "plural" artifacts */
2203 if (o_ptr->number != 1) return (FALSE);
2205 /* Check the artifact list (skip the "specials") */
2206 for (i = 0; i < max_a_idx; i++)
2208 artifact_type *a_ptr = &a_info[i];
2210 /* Skip "empty" items */
2211 if (!a_ptr->name) continue;
2213 /* Cannot make an artifact twice */
2214 if (a_ptr->cur_num) continue;
2216 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2218 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2220 /* Must have the correct fields */
2221 if (a_ptr->tval != o_ptr->tval) continue;
2222 if (a_ptr->sval != o_ptr->sval) continue;
2224 /* XXX XXX Enforce minimum "depth" (loosely) */
2225 if (a_ptr->level > dun_level)
2227 /* Acquire the "out-of-depth factor" */
2228 int d = (a_ptr->level - dun_level) * 2;
2230 /* Roll for out-of-depth creation */
2231 if (!one_in_(d)) continue;
2234 /* We must make the "rarity roll" */
2235 if (!one_in_(a_ptr->rarity)) continue;
2237 /* Hack -- mark the item as an artifact */
2240 /* Hack: Some artifacts get random extra powers */
2241 random_artifact_resistance(o_ptr, a_ptr);
2253 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2254 * Choose random ego type
2255 * @param slot 取得したいエゴの装備部位
2256 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2257 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2259 static byte get_random_ego(byte slot, bool good)
2262 ego_item_type *e_ptr;
2266 for (i = 1; i < max_e_idx; i++)
2270 if (e_ptr->slot == slot
2271 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2274 total += (255 / e_ptr->rarity);
2278 value = randint1(total);
2280 for (i = 1; i < max_e_idx; i++)
2284 if (e_ptr->slot == slot
2285 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2288 value -= (255 / e_ptr->rarity);
2289 if (value <= 0L) break;
2297 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2298 * Apply magic to an item known to be a "weapon"
2299 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2300 * @param level 生成基準階
2301 * @param power 生成ランク
2304 * Hack -- note special base damage dice boosting\n
2305 * Hack -- note special processing for weapon/digger\n
2307 static void a_m_aux_1(object_type *o_ptr, DEPTH level, int power)
2309 HIT_PROB tohit1 = randint1(5) + (HIT_PROB)m_bonus(5, level);
2310 HIT_POINT todam1 = randint1(5) + (HIT_POINT)m_bonus(5, level);
2312 HIT_PROB tohit2 = (HIT_PROB)m_bonus(10, level);
2313 HIT_POINT todam2 = (HIT_POINT)m_bonus(10, level);
2315 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2317 tohit2 = (tohit2+1)/2;
2318 todam2 = (todam2+1)/2;
2325 o_ptr->to_h += tohit1;
2326 o_ptr->to_d += todam1;
2332 o_ptr->to_h += tohit2;
2333 o_ptr->to_d += todam2;
2341 o_ptr->to_h -= tohit1;
2342 o_ptr->to_d -= todam1;
2347 /* Penalize again */
2348 o_ptr->to_h -= tohit2;
2349 o_ptr->to_d -= todam2;
2352 /* Cursed (if "bad") */
2353 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2356 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2359 switch (o_ptr->tval)
2366 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2367 create_artifact(o_ptr, FALSE);
2369 /* Special Ego-item */
2370 o_ptr->name2 = EGO_DIGGING;
2374 else if (power < -1)
2376 /* Hack -- Horrible digging bonus */
2377 o_ptr->pval = 0 - (5 + randint1(5));
2383 /* Hack -- Reverse digging bonus */
2384 o_ptr->pval = 0 - (o_ptr->pval);
2398 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2400 create_artifact(o_ptr, FALSE);
2405 /* Roll for an ego-item */
2406 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2407 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2409 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2411 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2416 switch (o_ptr->name2)
2419 if (one_in_(4) && (level > 40))
2420 add_flag(o_ptr->art_flags, TR_BLOWS);
2424 add_flag(o_ptr->art_flags, TR_RES_POIS);
2426 add_flag(o_ptr->art_flags, TR_WARNING);
2428 case EGO_KILL_DRAGON:
2430 add_flag(o_ptr->art_flags, TR_RES_POIS);
2434 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2436 case EGO_SLAYING_WEAPON:
2437 if (one_in_(3)) /* double damage */
2445 while (one_in_(o_ptr->dd));
2451 while (one_in_(o_ptr->ds));
2456 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2458 if (o_ptr->tval == TV_SWORD && one_in_(3))
2460 add_flag(o_ptr->art_flags, TR_VORPAL);
2465 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2471 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2473 add_flag(o_ptr->art_flags, TR_DEX);
2475 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2478 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, level) + 1;
2480 case EGO_EARTHQUAKES:
2481 if (one_in_(3) && (level > 60))
2482 add_flag(o_ptr->art_flags, TR_BLOWS);
2484 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, level);
2488 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2492 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2494 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2496 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2497 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2500 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2501 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2502 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2503 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2507 if (!o_ptr->art_name)
2509 /* Hack -- Super-charge the damage dice */
2510 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2512 /* Hack -- Lower the damage dice */
2513 if (o_ptr->dd > 9) o_ptr->dd = 9;
2518 else if (power < -1)
2520 /* Roll for ego-item */
2521 if (randint0(MAX_DEPTH) < level)
2525 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2526 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2532 switch (o_ptr->name2)
2535 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2536 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2538 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2539 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2540 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2541 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2542 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2543 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2557 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2559 create_artifact(o_ptr, FALSE);
2562 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2576 if (power > 2) /* power > 2 is debug only */
2578 create_artifact(o_ptr, FALSE);
2582 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2584 switch (o_ptr->name2)
2586 case EGO_SLAYING_BOLT:
2591 /* Hack -- super-charge the damage dice */
2592 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2594 /* Hack -- restrict the damage dice */
2595 if (o_ptr->dd > 9) o_ptr->dd = 9;
2599 else if (power < -1)
2601 /* Roll for ego-item */
2602 if (randint0(MAX_DEPTH) < level)
2604 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2614 * @brief ドラゴン装備にランダムな耐性を与える
2615 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2618 static void dragon_resist(object_type * o_ptr)
2623 one_dragon_ele_resistance(o_ptr);
2625 one_high_resistance(o_ptr);
2631 * @brief オブジェクトにランダムな強いESPを与える
2632 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2635 static bool add_esp_strong(object_type *o_ptr)
2637 bool nonliv = FALSE;
2639 switch (randint1(3))
2641 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2642 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2643 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2650 * @brief オブジェクトにランダムな弱いESPを与える
2651 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2652 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2655 static void add_esp_weak(object_type *o_ptr, bool extra)
2658 u32b weak_esp_list[] = {
2670 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2671 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2673 /* Add unduplicated weak esp flags randomly */
2674 for (i = 0; i < add_count; ++ i)
2676 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2678 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2679 weak_esp_list[choice] = weak_esp_list[i];
2685 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2686 * Apply magic to an item known to be "armor"
2687 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2688 * @param level 生成基準階
2689 * @param power 生成ランク
2692 * Hack -- note special processing for crown/helm\n
2693 * Hack -- note special processing for robe of permanence\n
2695 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2697 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
2698 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
2704 o_ptr->to_a += toac1;
2710 o_ptr->to_a += toac2;
2718 o_ptr->to_a -= toac1;
2723 /* Penalize again */
2724 o_ptr->to_a -= toac2;
2727 /* Cursed (if "bad") */
2728 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2733 switch (o_ptr->tval)
2737 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2738 create_artifact(o_ptr, FALSE);
2748 /* Hack -- Try for "Robes of the Magi" */
2749 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2750 (o_ptr->sval == SV_ROBE) &&
2751 (randint0(100) < 15))
2755 o_ptr->name2 = EGO_YOIYAMI;
2756 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2757 o_ptr->sval = SV_YOIYAMI_ROBE;
2763 o_ptr->name2 = EGO_PERMANENCE;
2768 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2770 create_artifact(o_ptr, FALSE);
2776 bool okay_flag = TRUE;
2778 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2780 switch (o_ptr->name2)
2783 if (o_ptr->tval != TV_HARD_ARMOR)
2789 if (o_ptr->tval != TV_SOFT_ARMOR)
2798 if (okay_flag) break;
2800 switch (o_ptr->name2)
2802 case EGO_RESISTANCE:
2804 add_flag(o_ptr->art_flags, TR_RES_POIS);
2807 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2808 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2812 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2814 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2816 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2817 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2819 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2820 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2821 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2822 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2823 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2824 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2825 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2826 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2829 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2830 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2831 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2832 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2833 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2834 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2847 if (o_ptr->sval == SV_DRAGON_SHIELD)
2849 dragon_resist(o_ptr);
2850 if (!one_in_(3)) break;
2856 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2858 create_artifact(o_ptr, FALSE);
2864 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2865 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2866 && o_ptr->name2 == EGO_S_DWARVEN)
2873 switch (o_ptr->name2)
2876 if (!one_in_(3)) one_high_resistance(o_ptr);
2877 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2879 case EGO_REFLECTION:
2880 if (o_ptr->sval == SV_MIRROR_SHIELD)
2885 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2886 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2895 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2897 dragon_resist(o_ptr);
2898 if (!one_in_(3)) break;
2902 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2904 create_artifact(o_ptr, FALSE);
2907 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2911 else if (power < -1)
2913 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2921 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2923 dragon_resist(o_ptr);
2924 if (!one_in_(3)) break;
2929 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2931 create_artifact(o_ptr, FALSE);
2934 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2936 switch (o_ptr->name2)
2938 case EGO_SLOW_DESCENT:
2941 one_high_resistance(o_ptr);
2947 else if (power < -1)
2949 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2960 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2962 create_artifact(o_ptr, FALSE);
2967 bool ok_flag = TRUE;
2968 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2970 switch (o_ptr->name2)
2973 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2974 else add_esp_weak(o_ptr, FALSE);
2978 case EGO_REGENERATION:
2979 case EGO_LORDLINESS:
2985 if (one_in_(2)) add_esp_strong(o_ptr);
2986 else add_esp_weak(o_ptr, FALSE);
2989 default:/* not existing crown (wisdom,lite, etc...) */
2993 break; /* while (1) */
2999 else if (power < -1)
3003 bool ok_flag = TRUE;
3004 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3006 switch (o_ptr->name2)
3008 case EGO_ANCIENT_CURSE:
3009 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3010 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3011 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3012 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3013 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3014 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3018 break; /* while (1) */
3027 if (o_ptr->sval == SV_DRAGON_HELM)
3029 dragon_resist(o_ptr);
3030 if (!one_in_(3)) break;
3036 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3038 create_artifact(o_ptr, FALSE);
3043 bool ok_flag = TRUE;
3044 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3046 switch (o_ptr->name2)
3048 case EGO_BRILLIANCE:
3050 case EGO_INFRAVISION:
3051 case EGO_H_PROTECTION:
3056 if (one_in_(2)) add_esp_strong(o_ptr);
3057 else add_esp_weak(o_ptr, FALSE);
3061 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3062 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3065 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3067 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3069 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3070 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3072 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3073 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3074 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3075 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3076 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3077 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3078 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3079 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3081 default:/* not existing helm (Magi, Might, etc...)*/
3085 break; /* while (1) */
3090 else if (power < -1)
3094 bool ok_flag = TRUE;
3095 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3097 switch (o_ptr->name2)
3099 case EGO_ANCIENT_CURSE:
3103 break; /* while (1) */
3114 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3116 create_artifact(o_ptr, FALSE);
3119 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3121 switch (o_ptr->name2)
3130 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3131 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3132 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3133 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3140 else if (power < -1)
3142 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3153 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3154 * Apply magic to an item known to be a "ring" or "amulet"
3155 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3156 * @param level 生成基準階
3157 * @param power 生成ランク
3160 * Hack -- note special "pval boost" code for ring of speed\n
3161 * Hack -- note that some items must be cursed (or blessed)\n
3163 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3165 /* Apply magic (good or bad) according to type */
3166 switch (o_ptr->tval)
3171 switch (o_ptr->sval)
3173 case SV_RING_ATTACKS:
3176 o_ptr->pval = (PARAMETER_VALUE)m_bonus(2, level);
3177 if (one_in_(15)) o_ptr->pval++;
3178 if (o_ptr->pval < 1) o_ptr->pval = 1;
3184 o_ptr->ident |= (IDENT_BROKEN);
3187 o_ptr->curse_flags |= TRC_CURSED;
3190 o_ptr->pval = 0 - (o_ptr->pval);
3201 /* Strength, Constitution, Dexterity, Intelligence */
3207 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3213 o_ptr->ident |= (IDENT_BROKEN);
3216 o_ptr->curse_flags |= TRC_CURSED;
3219 o_ptr->pval = 0 - (o_ptr->pval);
3225 /* Ring of Speed! */
3228 /* Base speed (1 to 10) */
3229 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3231 /* Super-charge the ring */
3232 while (randint0(100) < 50) o_ptr->pval++;
3238 o_ptr->ident |= (IDENT_BROKEN);
3241 o_ptr->curse_flags |= TRC_CURSED;
3244 o_ptr->pval = 0 - (o_ptr->pval);
3252 case SV_RING_LORDLY:
3256 one_lordly_high_resistance(o_ptr);
3260 /* Bonus to armor class */
3261 o_ptr->to_a = 10 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3265 case SV_RING_WARNING:
3267 if (one_in_(3)) one_low_esp(o_ptr);
3272 case SV_RING_SEARCHING:
3274 /* Bonus to searching */
3275 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3281 o_ptr->ident |= (IDENT_BROKEN);
3284 o_ptr->curse_flags |= TRC_CURSED;
3287 o_ptr->pval = 0 - (o_ptr->pval);
3293 /* Flames, Acid, Ice */
3294 case SV_RING_FLAMES:
3299 /* Bonus to armor class */
3300 o_ptr->to_a = 5 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3304 /* Weakness, Stupidity */
3305 case SV_RING_WEAKNESS:
3306 case SV_RING_STUPIDITY:
3309 o_ptr->ident |= (IDENT_BROKEN);
3312 o_ptr->curse_flags |= TRC_CURSED;
3315 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3316 if (power > 0) power = 0 - power;
3321 /* WOE, Stupidity */
3325 o_ptr->ident |= (IDENT_BROKEN);
3328 o_ptr->curse_flags |= TRC_CURSED;
3331 o_ptr->to_a = 0 - (5 + (ARMOUR_CLASS)m_bonus(10, level));
3332 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3333 if (power > 0) power = 0 - power;
3338 /* Ring of damage */
3339 case SV_RING_DAMAGE:
3341 /* Bonus to damage */
3342 o_ptr->to_d = 1 + randint1(5) + (HIT_POINT)m_bonus(16, level);
3348 o_ptr->ident |= (IDENT_BROKEN);
3351 o_ptr->curse_flags |= TRC_CURSED;
3354 o_ptr->to_d = 0 - o_ptr->to_d;
3360 /* Ring of Accuracy */
3361 case SV_RING_ACCURACY:
3364 o_ptr->to_h = 1 + randint1(5) + (HIT_PROB)m_bonus(16, level);
3370 o_ptr->ident |= (IDENT_BROKEN);
3373 o_ptr->curse_flags |= TRC_CURSED;
3376 o_ptr->to_h = 0 - o_ptr->to_h;
3382 /* Ring of Protection */
3383 case SV_RING_PROTECTION:
3385 /* Bonus to armor class */
3386 o_ptr->to_a = 5 + randint1(8) + (ARMOUR_CLASS)m_bonus(10, level);
3392 o_ptr->ident |= (IDENT_BROKEN);
3395 o_ptr->curse_flags |= TRC_CURSED;
3398 o_ptr->to_a = 0 - o_ptr->to_a;
3404 /* Ring of Slaying */
3405 case SV_RING_SLAYING:
3407 /* Bonus to damage and to hit */
3408 o_ptr->to_d = randint1(5) + (HIT_POINT)m_bonus(12, level);
3409 o_ptr->to_h = randint1(5) + (HIT_PROB)m_bonus(12, level);
3415 o_ptr->ident |= (IDENT_BROKEN);
3418 o_ptr->curse_flags |= TRC_CURSED;
3420 /* Reverse bonuses */
3421 o_ptr->to_h = 0 - o_ptr->to_h;
3422 o_ptr->to_d = 0 - o_ptr->to_d;
3428 case SV_RING_MUSCLE:
3430 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(3, level);
3431 if (one_in_(4)) o_ptr->pval++;
3437 o_ptr->ident |= (IDENT_BROKEN);
3440 o_ptr->curse_flags |= TRC_CURSED;
3442 /* Reverse bonuses */
3443 o_ptr->pval = 0 - o_ptr->pval;
3448 case SV_RING_AGGRAVATION:
3451 o_ptr->ident |= (IDENT_BROKEN);
3454 o_ptr->curse_flags |= TRC_CURSED;
3456 if (power > 0) power = 0 - power;
3460 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3461 || (power > 2)) /* power > 2 is debug only */
3463 o_ptr->pval = MIN(o_ptr->pval, 4);
3464 /* Randart amulet */
3465 create_artifact(o_ptr, FALSE);
3467 else if ((power == 2) && one_in_(2))
3469 while(!o_ptr->name2)
3471 int tmp = m_bonus(10, level);
3472 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3473 switch(randint1(28))
3476 o_ptr->name2 = EGO_RING_THROW;
3479 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3480 o_ptr->name2 = EGO_RING_REGEN;
3483 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3484 o_ptr->name2 = EGO_RING_LITE;
3487 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3488 o_ptr->name2 = EGO_RING_TELEPORT;
3491 if (o_ptr->to_h) break;
3492 o_ptr->name2 = EGO_RING_TO_H;
3495 if (o_ptr->to_d) break;
3496 o_ptr->name2 = EGO_RING_TO_D;
3499 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3500 o_ptr->name2 = EGO_RING_SLAY;
3503 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3504 o_ptr->name2 = EGO_RING_WIZARD;
3507 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3508 o_ptr->name2 = EGO_RING_HERO;
3511 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3512 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3513 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3514 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3517 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3518 if (!(have_flag(k_ptr->flags, TR_RES_FIRE)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3519 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3520 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3521 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3524 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3525 if (!(have_flag(k_ptr->flags, TR_RES_COLD)) && (have_flag(k_ptr->flags, TR_RES_FIRE) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3526 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3527 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3528 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3531 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3532 if (!(have_flag(k_ptr->flags, TR_RES_ELEC)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_FIRE) || have_flag(k_ptr->flags, TR_RES_ACID))) break;
3533 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3534 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3537 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3538 if (!(have_flag(k_ptr->flags, TR_RES_ACID)) && (have_flag(k_ptr->flags, TR_RES_COLD) || have_flag(k_ptr->flags, TR_RES_ELEC) || have_flag(k_ptr->flags, TR_RES_FIRE))) break;
3539 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3540 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3542 case 21: case 22: case 23: case 24: case 25: case 26:
3543 switch (o_ptr->sval)
3546 if (!one_in_(3)) break;
3547 o_ptr->name2 = EGO_RING_D_SPEED;
3549 case SV_RING_DAMAGE:
3550 case SV_RING_ACCURACY:
3551 case SV_RING_SLAYING:
3552 if (one_in_(2)) break;
3553 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3556 o_ptr->name2 = EGO_RING_BERSERKER;
3557 o_ptr->to_h -= 2+randint1(4);
3558 o_ptr->to_d += 2+randint1(4);
3561 case SV_RING_PROTECTION:
3562 o_ptr->name2 = EGO_RING_SUPER_AC;
3563 o_ptr->to_a += 7 + m_bonus(5, level);
3565 case SV_RING_RES_FEAR:
3566 o_ptr->name2 = EGO_RING_HERO;
3569 if (one_in_(2)) break;
3570 o_ptr->name2 = EGO_RING_HUNTER;
3572 case SV_RING_SEARCHING:
3573 o_ptr->name2 = EGO_RING_STEALTH;
3575 case SV_RING_TELEPORTATION:
3576 o_ptr->name2 = EGO_RING_TELE_AWAY;
3578 case SV_RING_RES_BLINDNESS:
3580 o_ptr->name2 = EGO_RING_RES_LITE;
3582 o_ptr->name2 = EGO_RING_RES_DARK;
3584 case SV_RING_LORDLY:
3585 if (!one_in_(20)) break;
3586 one_lordly_high_resistance(o_ptr);
3587 one_lordly_high_resistance(o_ptr);
3588 o_ptr->name2 = EGO_RING_TRUE;
3590 case SV_RING_SUSTAIN:
3591 if (!one_in_(4)) break;
3592 o_ptr->name2 = EGO_RING_RES_TIME;
3594 case SV_RING_FLAMES:
3595 if (!one_in_(2)) break;
3596 o_ptr->name2 = EGO_RING_DRAGON_F;
3599 if (!one_in_(2)) break;
3600 o_ptr->name2 = EGO_RING_DRAGON_C;
3602 case SV_RING_WARNING:
3603 if (!one_in_(2)) break;
3604 o_ptr->name2 = EGO_RING_M_DETECT;
3613 o_ptr->curse_flags = 0L;
3615 else if ((power == -2) && one_in_(2))
3617 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3618 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3619 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3620 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3621 o_ptr->art_flags[0] = 0;
3622 o_ptr->art_flags[1] = 0;
3623 while(!o_ptr->name2)
3625 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3629 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3630 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3633 o_ptr->name2 = EGO_RING_NO_MELEE;
3636 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3637 o_ptr->name2 = EGO_RING_AGGRAVATE;
3640 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3641 o_ptr->name2 = EGO_RING_TY_CURSE;
3644 o_ptr->name2 = EGO_RING_ALBINO;
3649 o_ptr->ident |= (IDENT_BROKEN);
3652 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3660 switch (o_ptr->sval)
3662 /* Amulet of wisdom/charisma */
3663 case SV_AMULET_INTELLIGENCE:
3664 case SV_AMULET_WISDOM:
3665 case SV_AMULET_CHARISMA:
3667 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3673 o_ptr->ident |= (IDENT_BROKEN);
3676 o_ptr->curse_flags |= (TRC_CURSED);
3678 /* Reverse bonuses */
3679 o_ptr->pval = 0 - o_ptr->pval;
3685 /* Amulet of brilliance */
3686 case SV_AMULET_BRILLIANCE:
3688 o_ptr->pval = 1 + m_bonus(3, level);
3689 if (one_in_(4)) o_ptr->pval++;
3695 o_ptr->ident |= (IDENT_BROKEN);
3698 o_ptr->curse_flags |= (TRC_CURSED);
3700 /* Reverse bonuses */
3701 o_ptr->pval = 0 - o_ptr->pval;
3707 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3711 o_ptr->curse_flags |= (TRC_CURSED);
3716 case SV_AMULET_RESISTANCE:
3718 if (one_in_(5)) one_high_resistance(o_ptr);
3719 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3723 /* Amulet of searching */
3724 case SV_AMULET_SEARCHING:
3726 o_ptr->pval = randint1(2) + (PARAMETER_VALUE)m_bonus(4, level);
3732 o_ptr->ident |= (IDENT_BROKEN);
3735 o_ptr->curse_flags |= (TRC_CURSED);
3737 /* Reverse bonuses */
3738 o_ptr->pval = 0 - (o_ptr->pval);
3744 /* Amulet of the Magi -- never cursed */
3745 case SV_AMULET_THE_MAGI:
3747 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3748 o_ptr->to_a = randint1(5) + (ARMOUR_CLASS)m_bonus(5, level);
3750 /* gain one low ESP */
3751 add_esp_weak(o_ptr, FALSE);
3756 /* Amulet of Doom -- always cursed */
3757 case SV_AMULET_DOOM:
3760 o_ptr->ident |= (IDENT_BROKEN);
3763 o_ptr->curse_flags |= (TRC_CURSED);
3766 o_ptr->pval = 0 - (randint1(5) + (PARAMETER_VALUE)m_bonus(5, level));
3767 o_ptr->to_a = 0 - (randint1(5) + (ARMOUR_CLASS)m_bonus(5, level));
3768 if (power > 0) power = 0 - power;
3773 case SV_AMULET_MAGIC_MASTERY:
3775 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(4, level);
3781 o_ptr->ident |= (IDENT_BROKEN);
3784 o_ptr->curse_flags |= (TRC_CURSED);
3786 /* Reverse bonuses */
3787 o_ptr->pval = 0 - o_ptr->pval;
3793 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3794 || (power > 2)) /* power > 2 is debug only */
3796 o_ptr->pval = MIN(o_ptr->pval, 4);
3797 /* Randart amulet */
3798 create_artifact(o_ptr, FALSE);
3800 else if ((power == 2) && one_in_(2))
3802 while(!o_ptr->name2)
3804 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3805 switch(randint1(21))
3808 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3809 o_ptr->name2 = EGO_AMU_SLOW_D;
3812 if (o_ptr->pval) break;
3813 o_ptr->name2 = EGO_AMU_INFRA;
3816 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3817 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3820 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3821 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3824 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3825 o_ptr->name2 = EGO_AMU_LEVITATION;
3827 case 10: case 11: case 21:
3828 o_ptr->name2 = EGO_AMU_AC;
3831 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3832 if (m_bonus(10, level) > 8)
3833 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3835 o_ptr->name2 = EGO_AMU_RES_FIRE;
3838 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3839 if (m_bonus(10, level) > 8)
3840 o_ptr->name2 = EGO_AMU_RES_COLD_;
3842 o_ptr->name2 = EGO_AMU_RES_COLD;
3845 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3846 if (m_bonus(10, level) > 8)
3847 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3849 o_ptr->name2 = EGO_AMU_RES_ELEC;
3852 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3853 if (m_bonus(10, level) > 8)
3854 o_ptr->name2 = EGO_AMU_RES_ACID_;
3856 o_ptr->name2 = EGO_AMU_RES_ACID;
3858 case 16: case 17: case 18: case 19: case 20:
3859 switch (o_ptr->sval)
3861 case SV_AMULET_TELEPORT:
3862 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3863 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3864 else o_ptr->name2 = EGO_AMU_TELEPORT;
3866 case SV_AMULET_RESIST_ACID:
3867 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3869 case SV_AMULET_SEARCHING:
3870 o_ptr->name2 = EGO_AMU_STEALTH;
3872 case SV_AMULET_BRILLIANCE:
3873 if (!one_in_(3)) break;
3874 o_ptr->name2 = EGO_AMU_IDENT;
3876 case SV_AMULET_CHARISMA:
3877 if (!one_in_(3)) break;
3878 o_ptr->name2 = EGO_AMU_CHARM;
3880 case SV_AMULET_THE_MAGI:
3881 if (one_in_(2)) break;
3882 o_ptr->name2 = EGO_AMU_GREAT;
3884 case SV_AMULET_RESISTANCE:
3885 if (!one_in_(5)) break;
3886 o_ptr->name2 = EGO_AMU_DEFENDER;
3888 case SV_AMULET_TELEPATHY:
3889 if (!one_in_(3)) break;
3890 o_ptr->name2 = EGO_AMU_DETECTION;
3896 o_ptr->curse_flags = 0L;
3898 else if ((power == -2) && one_in_(2))
3900 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3901 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3902 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3903 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3904 o_ptr->art_flags[0] = 0;
3905 o_ptr->art_flags[1] = 0;
3906 while(!o_ptr->name2)
3908 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3912 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3913 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3916 o_ptr->name2 = EGO_AMU_FOOL;
3919 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3920 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3923 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3924 o_ptr->name2 = EGO_AMU_TY_CURSE;
3927 o_ptr->name2 = EGO_AMU_NAIVETY;
3932 o_ptr->ident |= (IDENT_BROKEN);
3935 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3943 * @brief モンスターが人形のベースにできるかを返す
3944 * @param r_idx チェックしたいモンスター種族のID
3945 * @return 人形にできるならTRUEを返す
3947 static bool item_monster_okay(MONRACE_IDX r_idx)
3949 monster_race *r_ptr = &r_info[r_idx];
3952 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3953 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3954 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3955 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3956 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3957 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3965 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3966 * Apply magic to an item known to be "boring"
3967 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3968 * @param level 生成基準階
3969 * @param power 生成ランク
3972 * Hack -- note the special code for various items
3974 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3976 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3981 /* Apply magic (good or bad) according to type */
3982 switch (o_ptr->tval)
3991 o_ptr->ident |= (IDENT_BROKEN);
3994 o_ptr->curse_flags |= (TRC_CURSED);
4001 o_ptr->xtra4 = o_ptr->pval;
4007 /* Hack -- Torches -- random fuel */
4008 if (o_ptr->sval == SV_LITE_TORCH)
4010 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4014 /* Hack -- Lanterns -- random fuel */
4015 if (o_ptr->sval == SV_LITE_LANTERN)
4017 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4021 if (power > 2) /* power > 2 is debug only */
4023 create_artifact(o_ptr, FALSE);
4025 else if ((power == 2) || ((power == 1) && one_in_(3)))
4027 while (!o_ptr->name2)
4031 bool okay_flag = TRUE;
4033 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4035 switch (o_ptr->name2)
4038 if (o_ptr->sval == SV_LITE_FEANOR)
4046 else if (power == -2)
4048 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4050 switch (o_ptr->name2)
4052 case EGO_LITE_DARKNESS:
4055 if (o_ptr->sval == SV_LITE_TORCH)
4057 add_flag(o_ptr->art_flags, TR_LITE_M1);
4059 else if (o_ptr->sval == SV_LITE_LANTERN)
4061 add_flag(o_ptr->art_flags, TR_LITE_M2);
4063 else if (o_ptr->sval == SV_LITE_FEANOR)
4065 add_flag(o_ptr->art_flags, TR_LITE_M3);
4077 /* The wand or staff gets a number of initial charges equal
4078 * to between 1/2 (+1) and the full object kind's pval. -LM-
4080 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4086 /* Transfer the pval. -LM- */
4087 o_ptr->pval = k_ptr->pval;
4094 object_aware(o_ptr);
4095 object_known(o_ptr);
4101 PARAMETER_VALUE i = 1;
4104 monster_race *r_ptr;
4106 /* Pick a random non-unique monster race */
4109 i = randint1(max_r_idx - 1);
4111 if (!item_monster_okay(i)) continue;
4112 if (i == MON_TSUCHINOKO) continue;
4116 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4118 /* Ignore dead monsters */
4119 if (!r_ptr->rarity) continue;
4121 /* Ignore uncommon monsters */
4122 if (r_ptr->rarity > 100) continue;
4124 /* Prefer less out-of-depth monsters */
4125 if (randint0(check)) continue;
4132 /* Some figurines are cursed */
4133 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4140 PARAMETER_VALUE i = 1;
4145 monster_race *r_ptr;
4147 if (o_ptr->sval == SV_SKELETON)
4149 match = RF9_DROP_SKELETON;
4151 else if (o_ptr->sval == SV_CORPSE)
4153 match = RF9_DROP_CORPSE;
4156 /* Hack -- Remove the monster restriction */
4157 get_mon_num_prep(item_monster_okay, NULL);
4159 /* Pick a random non-unique monster race */
4162 i = get_mon_num(dun_level);
4166 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4168 /* Ignore dead monsters */
4169 if (!r_ptr->rarity) continue;
4171 /* Ignore corpseless monsters */
4172 if (!(r_ptr->flags9 & match)) continue;
4174 /* Prefer less out-of-depth monsters */
4175 if (randint0(check)) continue;
4183 object_aware(o_ptr);
4184 object_known(o_ptr);
4190 PARAMETER_VALUE i = 1;
4192 monster_race *r_ptr;
4194 /* Pick a random monster race */
4197 i = randint1(max_r_idx - 1);
4201 /* Ignore dead monsters */
4202 if (!r_ptr->rarity) continue;
4211 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4213 object_aware(o_ptr);
4214 object_known(o_ptr);
4221 DEPTH obj_level = k_info[o_ptr->k_idx].level;
4223 /* Hack -- skip ruined chests */
4224 if (obj_level <= 0) break;
4226 /* Hack -- pick a "difficulty" */
4227 o_ptr->pval = randint1(obj_level);
4228 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4230 o_ptr->xtra3 = dun_level + 5;
4232 /* Never exceed "difficulty" of 55 to 59 */
4233 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4241 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4242 * Complete the "creation" of an object by applying "magic" to the item
4243 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4245 * @param mode 生成オプション
4248 * This includes not only rolling for random bonuses, but also putting the\n
4249 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4250 * staffs, giving fuel to lites, and placing traps on chests.\n
4252 * In particular, note that "Instant Artifacts", if "created" by an external\n
4253 * routine, must pass through this function to complete the actual creation.\n
4255 * The base "chance" of the item being "good" increases with the "level"\n
4256 * parameter, which is usually derived from the dungeon level, being equal\n
4257 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4258 * the object is guaranteed to be "good". If an object is "good", then\n
4259 * the chance that the object will be "great" (ego-item or artifact), also\n
4260 * increases with the "level", being equal to half the level, plus 5, up to\n
4261 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4262 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4264 * If the object is not "good", there is a chance it will be "cursed", and\n
4265 * if it is "cursed", there is a chance it will be "broken". These chances\n
4266 * are related to the "good" / "great" chances above.\n
4268 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4269 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4271 * If "okay" is true, and the object is going to be "great", then there is\n
4272 * a chance that an artifact will be created. This is true even if both the\n
4273 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4274 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4276 void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
4278 int i, rolls, f1, f2, power;
4280 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4282 /* Maximum "level" for various things */
4283 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4285 /* Base chance of being "good" */
4288 /* Maximal chance of being "good" */
4289 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4291 /* Base chance of being "great" */
4294 /* Maximal chance of being "great" */
4295 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4296 f2 = d_info[dungeon_type].obj_great;
4298 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4303 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4312 /* Roll for "good" */
4313 if ((mode & AM_GOOD) || magik(f1))
4318 /* Roll for "great" */
4319 if ((mode & AM_GREAT) || magik(f2))
4323 /* Roll for "special" */
4324 if (mode & AM_SPECIAL) power = 3;
4328 /* Roll for "cursed" */
4331 /* Assume "cursed" */
4334 /* Roll for "broken" */
4335 if (magik(f2)) power = -2;
4339 if (mode & AM_CURSED)
4341 /* Assume 'cursed' */
4346 /* Everything else gets more badly cursed */
4353 /* Assume no rolls */
4356 /* Get one roll if excellent */
4357 if (power >= 2) rolls = 1;
4359 /* Hack -- Get four rolls if forced great or special */
4360 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4362 /* Hack -- Get no rolls if not allowed */
4363 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4365 /* Roll for artifacts if allowed */
4366 for (i = 0; i < rolls; i++)
4368 /* Roll for an artifact */
4369 if (make_artifact(o_ptr)) break;
4370 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4372 if (make_artifact(o_ptr)) break;
4377 /* Hack -- analyze artifacts */
4378 if (object_is_fixed_artifact(o_ptr))
4380 artifact_type *a_ptr = &a_info[o_ptr->name1];
4382 /* Hack -- Mark the artifact as "created" */
4385 /* Hack -- Memorize location of artifact in saved floors */
4386 if (character_dungeon)
4387 a_ptr->floor_id = p_ptr->floor_id;
4389 /* Extract the other fields */
4390 o_ptr->pval = a_ptr->pval;
4391 o_ptr->ac = a_ptr->ac;
4392 o_ptr->dd = a_ptr->dd;
4393 o_ptr->ds = a_ptr->ds;
4394 o_ptr->to_a = a_ptr->to_a;
4395 o_ptr->to_h = a_ptr->to_h;
4396 o_ptr->to_d = a_ptr->to_d;
4397 o_ptr->weight = a_ptr->weight;
4398 o_ptr->xtra2 = a_ptr->act_idx;
4400 if (o_ptr->name1 == ART_MILIM)
4402 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4408 /* Hack -- extract the "broken" flag */
4409 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4411 /* Hack -- extract the "cursed" flag */
4412 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4413 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4414 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4415 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4416 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4417 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4425 switch (o_ptr->tval)
4434 if (power) a_m_aux_1(o_ptr, lev, power);
4440 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4446 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4460 /* Elven Cloak and Black Clothes ... */
4461 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4462 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4463 o_ptr->pval = randint1(4);
4467 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4468 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4469 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4470 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4471 a_m_aux_2(o_ptr, lev, power);
4473 if (power) a_m_aux_2(o_ptr, lev, power);
4481 if (!power && (randint0(100) < 50)) power = -1;
4482 a_m_aux_3(o_ptr, lev, power);
4488 a_m_aux_4(o_ptr, lev, power);
4493 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4494 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4495 (p_ptr->pseikaku == SEIKAKU_SEXY))
4498 add_flag(o_ptr->art_flags, TR_STR);
4499 add_flag(o_ptr->art_flags, TR_INT);
4500 add_flag(o_ptr->art_flags, TR_WIS);
4501 add_flag(o_ptr->art_flags, TR_DEX);
4502 add_flag(o_ptr->art_flags, TR_CON);
4503 add_flag(o_ptr->art_flags, TR_CHR);
4506 /* Hack -- analyze ego-items */
4507 if (object_is_ego(o_ptr))
4509 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4511 /* Hack -- acquire "broken" flag */
4512 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4514 /* Hack -- acquire "cursed" flag */
4515 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4516 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4517 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4518 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4519 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4520 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4522 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4523 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4524 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4525 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4526 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4527 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4528 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4529 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4535 while (one_in_(o_ptr->dd));
4537 if (o_ptr->dd > 9) o_ptr->dd = 9;
4540 /* Hack -- apply activatin index if needed */
4541 if (e_ptr->act_idx) o_ptr->xtra2 = (XTRA8)e_ptr->act_idx;
4543 /* Hack -- apply extra penalties if needed */
4544 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4546 /* Hack -- obtain bonuses */
4547 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4548 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4549 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4551 /* Hack -- obtain pval */
4552 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4555 /* Hack -- apply extra bonuses if needed */
4558 /* Hack -- obtain bonuses */
4559 if (e_ptr->max_to_h)
4561 if (e_ptr->max_to_h > 127)
4562 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4563 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4565 if (e_ptr->max_to_d)
4567 if (e_ptr->max_to_d > 127)
4568 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4569 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4571 if (e_ptr->max_to_a)
4573 if (e_ptr->max_to_a > 127)
4574 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4575 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4578 /* Accuracy ego must have high to_h */
4579 if(o_ptr->name2 == EGO_ACCURACY)
4581 while(o_ptr->to_h < o_ptr->to_d + 10)
4586 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4589 /* Accuracy ego must have high to_h */
4590 if(o_ptr->name2 == EGO_VELOCITY)
4592 while(o_ptr->to_d < o_ptr->to_h + 10)
4597 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4600 /* Protection ego must have high to_a */
4601 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4603 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4606 /* Hack -- obtain pval */
4607 if (e_ptr->max_pval)
4609 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4612 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4614 else if (o_ptr->name2 == EGO_DEMON)
4616 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4618 o_ptr->pval += randint1(2);
4622 o_ptr->pval += randint1(e_ptr->max_pval);
4625 else if (o_ptr->name2 == EGO_ATTACKS)
4627 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4628 if (o_ptr->pval > 3) o_ptr->pval = 3;
4629 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4630 o_ptr->pval += randint1(2);
4632 else if (o_ptr->name2 == EGO_BAT)
4634 o_ptr->pval = randint1(e_ptr->max_pval);
4635 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4637 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4639 o_ptr->pval = randint1(e_ptr->max_pval);
4643 o_ptr->pval += randint1(e_ptr->max_pval);
4648 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4650 o_ptr->pval = randint1(o_ptr->pval);
4652 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4660 /* Examine real objects */
4663 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4665 /* Hack -- acquire "broken" flag */
4666 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4668 /* Hack -- acquire "cursed" flag */
4669 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4670 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4671 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4672 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4673 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4674 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4682 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4683 * Hack -- determine if a template is "good"
4684 * @param k_idx 判定したいベースアイテムのID
4685 * @return ベースアイテムが上質ならばTRUEを返す。
4687 static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4689 object_kind *k_ptr = &k_info[k_idx];
4691 /* Analyze the item type */
4692 switch (k_ptr->tval)
4694 /* Armor -- Good unless damaged */
4705 if (k_ptr->to_a < 0) return (FALSE);
4709 /* Weapons -- Good unless damaged */
4716 if (k_ptr->to_h < 0) return (FALSE);
4717 if (k_ptr->to_d < 0) return (FALSE);
4721 /* Ammo -- Arrows/Bolts are good */
4728 /* Books -- High level books are good (except Arcane books) */
4730 case TV_SORCERY_BOOK:
4731 case TV_NATURE_BOOK:
4736 case TV_DAEMON_BOOK:
4737 case TV_CRUSADE_BOOK:
4739 case TV_HISSATSU_BOOK:
4742 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4746 /* Rings -- Rings of Speed are good */
4749 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4750 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4754 /* Amulets -- Amulets of the Magi and Resistance are good */
4757 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4758 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4763 /* Assume not good */
4768 * @brief 生成階に応じたベースアイテムの生成を行う。
4769 * Attempt to make an object (normal or good/great)
4770 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4771 * @param mode オプションフラグ
4772 * @return 生成に成功したらTRUEを返す。
4774 * This routine plays nasty games to generate the "special artifacts".\n
4775 * This routine uses "object_level" for the "generation level".\n
4776 * We assume that the given object has been "wiped".\n
4778 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
4783 /* Chance of "special object" */
4784 prob = ((mode & AM_GOOD) ? 10 : 1000);
4786 /* Base level for the object */
4787 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4790 /* Generate a special object, or a normal object */
4791 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4796 if ((mode & AM_GOOD) && !get_obj_num_hook)
4798 /* Activate restriction (if already specified, use that) */
4799 get_obj_num_hook = kind_is_good;
4802 /* Restricted objects - prepare allocation table */
4803 if (get_obj_num_hook) get_obj_num_prep();
4805 /* Pick a random object */
4806 k_idx = get_obj_num(base);
4808 /* Restricted objects */
4809 if (get_obj_num_hook)
4811 /* Clear restriction */
4812 get_obj_num_hook = NULL;
4814 /* Reset allocation table to default */
4818 /* Handle failure */
4819 if (!k_idx) return (FALSE);
4821 /* Prepare the object */
4822 object_prep(j_ptr, k_idx);
4825 /* Apply magic (allow artifacts) */
4826 apply_magic(j_ptr, object_level, mode);
4828 /* Hack -- generate multiple spikes/missiles */
4829 switch (j_ptr->tval)
4837 j_ptr->number = (byte)damroll(6, 7);
4841 if (cheat_peek) object_mention(j_ptr);
4849 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4850 * Attempt to place an object (normal or good/great) at the given location.
4851 * @param y 配置したいフロアのY座標
4852 * @param x 配置したいフロアのX座標
4853 * @param mode オプションフラグ
4854 * @return 生成に成功したらTRUEを返す。
4856 * This routine plays nasty games to generate the "special artifacts".\n
4857 * This routine uses "object_level" for the "generation level".\n
4858 * This routine requires a clean floor grid destination.\n
4860 void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
4865 cave_type *c_ptr = &cave[y][x];
4871 /* Paranoia -- check bounds */
4872 if (!in_bounds(y, x)) return;
4874 /* Require floor space */
4875 if (!cave_drop_bold(y, x)) return;
4877 /* Avoid stacking on other objects */
4878 if (c_ptr->o_idx) return;
4881 /* Get local object */
4884 /* Wipe the object */
4887 /* Make an object (if possible) */
4888 if (!make_object(q_ptr, mode)) return;
4891 /* Make an object */
4899 /* Acquire object */
4900 o_ptr = &o_list[o_idx];
4902 /* Structure Copy */
4903 object_copy(o_ptr, q_ptr);
4910 o_ptr->next_o_idx = c_ptr->o_idx;
4912 /* Place the object */
4913 c_ptr->o_idx = o_idx;
4923 /* Hack -- Preserve artifacts */
4924 if (object_is_fixed_artifact(q_ptr))
4926 a_info[q_ptr->name1].cur_num = 0;
4933 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4934 * Make a treasure object
4935 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4936 * @return 生成に成功したらTRUEを返す。
4938 * The location must be a legal, clean, floor grid.
4940 bool make_gold(object_type *j_ptr)
4945 /* Hack -- Pick a Treasure variety */
4946 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4948 /* Apply "extra" magic */
4949 if (one_in_(GREAT_OBJ))
4951 i += randint1(object_level + 1);
4954 /* Hack -- Creeping Coins only generate "themselves" */
4955 if (coin_type) i = coin_type;
4957 /* Do not create "illegal" Treasure Types */
4958 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4960 /* Prepare a gold object */
4961 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4963 /* Hack -- Base coin cost */
4964 base = k_info[OBJ_GOLD_LIST + i].cost;
4966 /* Determine how much the treasure is "worth" */
4967 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4975 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
4976 * Places a treasure (Gold or Gems) at given location
4977 * @param y 配置したいフロアのY座標
4978 * @param x 配置したいフロアのX座標
4979 * @return 生成に成功したらTRUEを返す。
4981 * The location must be a legal, clean, floor grid.
4983 void place_gold(POSITION y, POSITION x)
4988 cave_type *c_ptr = &cave[y][x];
4994 /* Paranoia -- check bounds */
4995 if (!in_bounds(y, x)) return;
4997 /* Require floor space */
4998 if (!cave_drop_bold(y, x)) return;
5000 /* Avoid stacking on other objects */
5001 if (c_ptr->o_idx) return;
5004 /* Get local object */
5007 /* Wipe the object */
5010 /* Make some gold */
5011 if (!make_gold(q_ptr)) return;
5013 /* Make an object */
5021 /* Acquire object */
5022 o_ptr = &o_list[o_idx];
5024 /* Copy the object */
5025 object_copy(o_ptr, q_ptr);
5032 o_ptr->next_o_idx = c_ptr->o_idx;
5034 /* Place the object */
5035 c_ptr->o_idx = o_idx;
5047 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5048 * Let an object fall to the ground at or near a location.
5049 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5050 * @param chance ドロップの成功率(%)
5051 * @param y 配置したいフロアのY座標
5052 * @param x 配置したいフロアのX座標
5053 * @return 生成に成功したらオブジェクトのIDを返す。
5055 * The initial location is assumed to be "in_bounds()".\n
5057 * This function takes a parameter "chance". This is the percentage\n
5058 * chance that the item will "disappear" instead of drop. If the object\n
5059 * has been thrown, then this is the chance of disappearance on contact.\n
5061 * Hack -- this function uses "chance" to determine if it should produce\n
5062 * some form of "description" of the drop event (under the player).\n
5064 * We check several locations to see if we can find a location at which\n
5065 * the object can combine, stack, or be placed. Artifacts will try very\n
5066 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5068 OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION x)
5075 POSITION ty, tx = 0;
5077 OBJECT_IDX o_idx = 0;
5078 OBJECT_IDX this_o_idx, next_o_idx = 0;
5082 char o_name[MAX_NLEN];
5088 /* Extract plural */
5089 bool plural = (j_ptr->number != 1);
5092 /* Describe object */
5093 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5096 /* Handle normal "breakage" */
5097 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5101 msg_format("%sは消えた。", o_name);
5103 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5106 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5123 /* Scan local grids */
5124 for (dy = -3; dy <= 3; dy++)
5126 /* Scan local grids */
5127 for (dx = -3; dx <= 3; dx++)
5131 /* Calculate actual distance */
5132 d = (dy * dy) + (dx * dx);
5134 /* Ignore distant grids */
5135 if (d > 10) continue;
5141 /* Skip illegal grids */
5142 if (!in_bounds(ty, tx)) continue;
5144 /* Require line of projection */
5145 if (!projectable(y, x, ty, tx)) continue;
5148 c_ptr = &cave[ty][tx];
5150 /* Require floor space */
5151 if (!cave_drop_bold(ty, tx)) continue;
5156 /* Scan objects in that grid */
5157 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5161 /* Acquire object */
5162 o_ptr = &o_list[this_o_idx];
5164 /* Acquire next object */
5165 next_o_idx = o_ptr->next_o_idx;
5167 /* Check for possible combination */
5168 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5174 /* Add new object */
5178 if (k > 99) continue;
5180 /* Calculate score */
5181 s = 1000 - (d + k * 5);
5183 /* Skip bad values */
5184 if (s < bs) continue;
5186 /* New best value */
5189 /* Apply the randomizer to equivalent values */
5190 if ((++bn >= 2) && !one_in_(bn)) continue;
5205 /* Handle lack of space */
5206 if (!flag && !object_is_artifact(j_ptr))
5210 msg_format("%sは消えた。", o_name);
5212 msg_format("The %s disappear%s.",
5213 o_name, (plural ? "" : "s"));
5218 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5226 for (i = 0; !flag && (i < 1000); i++)
5229 ty = rand_spread(by, 1);
5230 tx = rand_spread(bx, 1);
5232 /* Verify location */
5233 if (!in_bounds(ty, tx)) continue;
5235 /* Bounce to that location */
5239 /* Require floor space */
5240 if (!cave_drop_bold(by, bx)) continue;
5249 int candidates = 0, pick;
5251 for (ty = 1; ty < cur_hgt - 1; ty++)
5253 for (tx = 1; tx < cur_wid - 1; tx++)
5255 /* A valid space found */
5256 if (cave_drop_bold(ty, tx)) candidates++;
5260 /* No valid place! */
5265 msg_format("%sは消えた。", o_name);
5267 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5271 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5273 /* Mega-Hack -- preserve artifacts */
5276 /* Hack -- Preserve unknown artifacts */
5277 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5279 /* Mega-Hack -- Preserve the artifact */
5280 a_info[j_ptr->name1].cur_num = 0;
5288 /* Choose a random one */
5289 pick = randint1(candidates);
5291 for (ty = 1; ty < cur_hgt - 1; ty++)
5293 for (tx = 1; tx < cur_wid - 1; tx++)
5295 if (cave_drop_bold(ty, tx))
5299 /* Is this a picked one? */
5313 c_ptr = &cave[by][bx];
5315 /* Scan objects in that grid for combination */
5316 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5320 /* Acquire object */
5321 o_ptr = &o_list[this_o_idx];
5323 /* Acquire next object */
5324 next_o_idx = o_ptr->next_o_idx;
5326 /* Check for combination */
5327 if (object_similar(o_ptr, j_ptr))
5329 /* Combine the items */
5330 object_absorb(o_ptr, j_ptr);
5340 /* Get new object */
5341 if (!done) o_idx = o_pop();
5344 if (!done && !o_idx)
5348 msg_format("%sは消えた。", o_name);
5350 msg_format("The %s disappear%s.",
5351 o_name, (plural ? "" : "s"));
5356 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5358 /* Hack -- Preserve artifacts */
5359 if (object_is_fixed_artifact(j_ptr))
5361 a_info[j_ptr->name1].cur_num = 0;
5371 /* Structure copy */
5372 object_copy(&o_list[o_idx], j_ptr);
5374 /* Access new object */
5375 j_ptr = &o_list[o_idx];
5382 j_ptr->held_m_idx = 0;
5385 j_ptr->next_o_idx = c_ptr->o_idx;
5387 /* Place the object */
5388 c_ptr->o_idx = o_idx;
5403 /* Mega-Hack -- no message if "dropped" by player */
5404 /* Message when an object falls under the player */
5405 if (chance && player_bold(by, bx))
5407 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5419 * Scatter some "great" objects near the player
5420 * @param y1 配置したいフロアのY座標
5421 * @param x1 配置したいフロアのX座標
5422 * @param num 獲得の処理回数
5423 * @param great TRUEならば必ず高級品以上を落とす
5424 * @param special TRUEならば必ず特別品を落とす
5425 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5428 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
5431 object_type object_type_body;
5432 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5437 /* Get local object */
5438 i_ptr = &object_type_body;
5440 /* Wipe the object */
5443 /* Make a good (or great) object (if possible) */
5444 if (!make_object(i_ptr, mode)) continue;
5448 object_aware(i_ptr);
5449 object_known(i_ptr);
5452 /* Drop the object */
5453 (void)drop_near(i_ptr, -1, y1, x1);
5458 * Scatter some "amusing" objects near the player
5461 #define AMS_NOTHING 0x00 /* No restriction */
5462 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5463 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5464 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5465 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5469 OBJECT_TYPE_VALUE tval;
5470 OBJECT_SUBTYPE_VALUE sval;
5475 amuse_type amuse_info[] =
5477 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5478 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5479 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5480 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5481 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5482 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5483 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5484 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5485 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5486 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5487 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5488 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5489 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5496 * @param y1 配置したいフロアのY座標
5497 * @param x1 配置したいフロアのX座標
5498 * @param num 誰得の処理回数
5499 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5502 void amusement(POSITION y1, POSITION x1, int num, bool known)
5505 object_type object_type_body;
5508 for (n = 0; amuse_info[n].tval != 0; n++)
5510 t += amuse_info[n].prob;
5517 IDX k_idx, a_idx = 0;
5518 int r = randint0(t);
5519 bool insta_art, fixed_art;
5523 r -= amuse_info[i].prob;
5527 /* Get local object */
5528 i_ptr = &object_type_body;
5530 /* Wipe the object */
5533 /* Wipe the object */
5534 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5536 /* Paranoia - reroll if nothing */
5537 if (!k_idx) continue;
5539 /* Search an artifact index if need */
5540 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5541 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5543 if (insta_art || fixed_art)
5545 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5547 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5548 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5549 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5550 if (a_info[a_idx].cur_num > 0) continue;
5554 if (a_idx >= max_a_idx) continue;
5557 /* Make an object (if possible) */
5558 object_prep(i_ptr, k_idx);
5559 if (a_idx) i_ptr->name1 = a_idx;
5560 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5562 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5564 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5567 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5568 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5572 object_aware(i_ptr);
5573 object_known(i_ptr);
5576 /* Paranoia - reroll if nothing */
5577 if (!(i_ptr->k_idx)) continue;
5579 /* Drop the object */
5580 (void)drop_near(i_ptr, -1, y1, x1);
5588 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5589 * Describe the charges on an item in the inventory.
5590 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5593 void inven_item_charges(int item)
5595 object_type *o_ptr = &inventory[item];
5597 /* Require staff/wand */
5598 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5600 /* Require known item */
5601 if (!object_is_known(o_ptr)) return;
5604 if (o_ptr->pval <= 0)
5606 msg_print("もう魔力が残っていない。");
5610 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5613 /* Multiple charges */
5614 if (o_ptr->pval != 1)
5616 /* Print a message */
5617 msg_format("You have %d charges remaining.", o_ptr->pval);
5623 /* Print a message */
5624 msg_format("You have %d charge remaining.", o_ptr->pval);
5631 * @brief アイテムの残り所持数メッセージを表示する /
5632 * Describe an item in the inventory.
5633 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5636 void inven_item_describe(int item)
5638 object_type *o_ptr = &inventory[item];
5639 char o_name[MAX_NLEN];
5641 /* Get a description */
5642 object_desc(o_name, o_ptr, 0);
5644 /* Print a message */
5646 /* "no more" の場合はこちらで表示する */
5647 if (o_ptr->number <= 0)
5649 /*FIRST*//*ここはもう通らないかも */
5650 msg_format("もう%sを持っていない。", o_name);
5654 /* アイテム名を英日切り替え機能対応 */
5655 msg_format("まだ %sを持っている。", o_name);
5658 msg_format("You have %s.", o_name);
5664 * @brief アイテムの残り所持数メッセージを表示する /
5665 * Increase the "number" of an item in the inventory
5666 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5670 void inven_item_increase(int item, int num)
5672 object_type *o_ptr = &inventory[item];
5675 num += o_ptr->number;
5678 if (num > 255) num = 255;
5679 else if (num < 0) num = 0;
5682 num -= (ITEM_NUMBER)o_ptr->number;
5684 /* Change the number and weight */
5687 /* Add the number */
5688 o_ptr->number += num;
5690 /* Add the weight */
5691 p_ptr->total_weight += (num * o_ptr->weight);
5693 /* Recalculate bonuses */
5694 p_ptr->update |= (PU_BONUS);
5696 /* Recalculate mana XXX */
5697 p_ptr->update |= (PU_MANA);
5699 /* Combine the pack */
5700 p_ptr->notice |= (PN_COMBINE);
5703 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5705 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5706 if (!o_ptr->number && p_ptr->ele_attack)
5708 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5710 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5712 /* Clear all temporary elemental brands */
5713 set_ele_attack(0, 0);
5721 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5722 * Erase an inventory slot if it has no more items
5723 * @param item 消去したいプレイヤーのアイテム所持スロット
5726 void inven_item_optimize(int item)
5728 object_type *o_ptr = &inventory[item];
5730 /* Only optimize real items */
5731 if (!o_ptr->k_idx) return;
5733 /* Only optimize empty items */
5734 if (o_ptr->number) return;
5736 /* The item is in the pack */
5737 if (item < INVEN_RARM)
5744 /* Slide everything down */
5745 for (i = item; i < INVEN_PACK; i++)
5747 /* Structure copy */
5748 inventory[i] = inventory[i+1];
5751 /* Erase the "final" slot */
5752 object_wipe(&inventory[i]);
5755 p_ptr->window |= (PW_INVEN);
5758 /* The item is being wielded */
5764 /* Erase the empty slot */
5765 object_wipe(&inventory[item]);
5767 /* Recalculate bonuses */
5768 p_ptr->update |= (PU_BONUS);
5770 /* Recalculate torch */
5771 p_ptr->update |= (PU_TORCH);
5773 /* Recalculate mana XXX */
5774 p_ptr->update |= (PU_MANA);
5777 p_ptr->window |= (PW_EQUIP);
5781 p_ptr->window |= (PW_SPELL);
5785 * @brief 床上の魔道具の残り残量メッセージを表示する /
5786 * Describe the charges on an item on the floor.
5787 * @param item メッセージの対象にしたいアイテム所持スロット
5790 void floor_item_charges(int item)
5792 object_type *o_ptr = &o_list[item];
5794 /* Require staff/wand */
5795 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5797 /* Require known item */
5798 if (!object_is_known(o_ptr)) return;
5801 if (o_ptr->pval <= 0)
5803 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5807 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5810 /* Multiple charges */
5811 if (o_ptr->pval != 1)
5813 /* Print a message */
5814 msg_format("There are %d charges remaining.", o_ptr->pval);
5820 /* Print a message */
5821 msg_format("There is %d charge remaining.", o_ptr->pval);
5828 * @brief 床上のアイテムの残り数メッセージを表示する /
5829 * Describe the charges on an item on the floor.
5830 * @param item メッセージの対象にしたいアイテム所持スロット
5833 void floor_item_describe(int item)
5835 object_type *o_ptr = &o_list[item];
5836 char o_name[MAX_NLEN];
5838 /* Get a description */
5839 object_desc(o_name, o_ptr, 0);
5841 /* Print a message */
5843 /* "no more" の場合はこちらで表示を分ける */
5844 if (o_ptr->number <= 0)
5846 msg_format("床上には、もう%sはない。", o_name);
5850 msg_format("床上には、まだ %sがある。", o_name);
5853 msg_format("You see %s.", o_name);
5860 * @brief 床上のアイテムの数を増やす /
5861 * Increase the "number" of an item on the floor
5862 * @param item 増やしたいアイテムの所持スロット
5863 * @param num 増やしたいアイテムの数
5866 void floor_item_increase(int item, int num)
5868 object_type *o_ptr = &o_list[item];
5871 num += o_ptr->number;
5874 if (num > 255) num = 255;
5875 else if (num < 0) num = 0;
5878 num -= (int)o_ptr->number;
5880 /* Change the number */
5881 o_ptr->number += (ITEM_NUMBER)num;
5886 * @brief 床上の数の無くなったアイテムスロットを消去する /
5887 * Optimize an item on the floor (destroy "empty" items)
5888 * @param item 消去したいアイテムの所持スロット
5891 void floor_item_optimize(int item)
5893 object_type *o_ptr = &o_list[item];
5895 /* Paranoia -- be sure it exists */
5896 if (!o_ptr->k_idx) return;
5898 /* Only optimize empty items */
5899 if (o_ptr->number) return;
5901 /* Delete the object */
5902 delete_object_idx(item);
5907 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
5908 * Check if we have space for an item in the pack without overflow
5909 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
5910 * @return 溢れずに済むならTRUEを返す
5912 bool inven_carry_okay(object_type *o_ptr)
5917 if (inven_cnt < INVEN_PACK) return (TRUE);
5920 for (j = 0; j < INVEN_PACK; j++)
5922 object_type *j_ptr = &inventory[j];
5924 /* Skip non-objects */
5925 if (!j_ptr->k_idx) continue;
5927 /* Check if the two items can be combined */
5928 if (object_similar(j_ptr, o_ptr)) return (TRUE);
5936 * @brief オブジェクトを定義された基準に従いソートするための関数 /
5937 * Check if we have space for an item in the pack without overflow
5938 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
5939 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
5940 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
5941 * @return o_ptrの方が上位ならばTRUEを返す。
5943 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
5947 /* Use empty slots */
5948 if (!j_ptr->k_idx) return TRUE;
5950 /* Hack -- readable books always come first */
5951 if ((o_ptr->tval == REALM1_BOOK) &&
5952 (j_ptr->tval != REALM1_BOOK)) return TRUE;
5953 if ((j_ptr->tval == REALM1_BOOK) &&
5954 (o_ptr->tval != REALM1_BOOK)) return FALSE;
5956 if ((o_ptr->tval == REALM2_BOOK) &&
5957 (j_ptr->tval != REALM2_BOOK)) return TRUE;
5958 if ((j_ptr->tval == REALM2_BOOK) &&
5959 (o_ptr->tval != REALM2_BOOK)) return FALSE;
5961 /* Objects sort by decreasing type */
5962 if (o_ptr->tval > j_ptr->tval) return TRUE;
5963 if (o_ptr->tval < j_ptr->tval) return FALSE;
5965 /* Non-aware (flavored) items always come last */
5966 /* Can happen in the home */
5967 if (!object_is_aware(o_ptr)) return FALSE;
5968 if (!object_is_aware(j_ptr)) return TRUE;
5970 /* Objects sort by increasing sval */
5971 if (o_ptr->sval < j_ptr->sval) return TRUE;
5972 if (o_ptr->sval > j_ptr->sval) return FALSE;
5974 /* Unidentified objects always come last */
5975 /* Objects in the home can be unknown */
5976 if (!object_is_known(o_ptr)) return FALSE;
5977 if (!object_is_known(j_ptr)) return TRUE;
5979 /* Fixed artifacts, random artifacts and ego items */
5980 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
5981 else if (o_ptr->art_name) o_type = 2;
5982 else if (object_is_ego(o_ptr)) o_type = 1;
5985 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
5986 else if (j_ptr->art_name) j_type = 2;
5987 else if (object_is_ego(j_ptr)) j_type = 1;
5990 if (o_type < j_type) return TRUE;
5991 if (o_type > j_type) return FALSE;
5993 switch (o_ptr->tval)
5999 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6000 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6006 /* Objects sort by increasing hit/damage bonuses */
6007 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6008 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6011 /* Hack: otherwise identical rods sort by
6012 increasing recharge time --dsb */
6014 if (o_ptr->pval < j_ptr->pval) return TRUE;
6015 if (o_ptr->pval > j_ptr->pval) return FALSE;
6019 /* Objects sort by decreasing value */
6020 return o_value > object_value(j_ptr);
6025 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6026 * Add an item to the players inventory, and return the slot used.
6027 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6028 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6030 * If the new item can combine with an existing item in the inventory,\n
6031 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6032 * the item will be placed into the "proper" location in the inventory.\n
6034 * This function can be used to "over-fill" the player's pack, but only\n
6035 * once, and such an action must trigger the "overflow" code immediately.\n
6036 * Note that when the pack is being "over-filled", the new item must be\n
6037 * placed into the "overflow" slot, and the "overflow" must take place\n
6038 * before the pack is reordered, but (optionally) after the pack is\n
6039 * combined. This may be tricky. See "dungeon.c" for info.\n
6041 * Note that this code must remove any location/stack information\n
6042 * from the object once it is placed into the inventory.\n
6044 s16b inven_carry(object_type *o_ptr)
6046 INVENTORY_IDX i, j, k;
6047 INVENTORY_IDX n = -1;
6052 /* Check for combining */
6053 for (j = 0; j < INVEN_PACK; j++)
6055 j_ptr = &inventory[j];
6057 /* Skip non-objects */
6058 if (!j_ptr->k_idx) continue;
6060 /* Hack -- track last item */
6063 /* Check if the two items can be combined */
6064 if (object_similar(j_ptr, o_ptr))
6066 /* Combine the items */
6067 object_absorb(j_ptr, o_ptr);
6069 /* Increase the weight */
6070 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6072 /* Recalculate bonuses */
6073 p_ptr->update |= (PU_BONUS);
6076 p_ptr->window |= (PW_INVEN);
6085 if (inven_cnt > INVEN_PACK) return (-1);
6087 /* Find an empty slot */
6088 for (j = 0; j <= INVEN_PACK; j++)
6090 j_ptr = &inventory[j];
6092 /* Use it if found */
6093 if (!j_ptr->k_idx) break;
6100 /* Reorder the pack */
6103 /* Get the "value" of the item */
6104 s32b o_value = object_value(o_ptr);
6106 /* Scan every occupied slot */
6107 for (j = 0; j < INVEN_PACK; j++)
6109 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6116 for (k = n; k >= i; k--)
6118 /* Hack -- Slide the item */
6119 object_copy(&inventory[k+1], &inventory[k]);
6122 /* Wipe the empty slot */
6123 object_wipe(&inventory[i]);
6128 object_copy(&inventory[i], o_ptr);
6130 /* Access new object */
6131 j_ptr = &inventory[i];
6134 j_ptr->next_o_idx = 0;
6136 /* Forget monster */
6137 j_ptr->held_m_idx = 0;
6139 /* Forget location */
6140 j_ptr->iy = j_ptr->ix = 0;
6142 /* Player touches it, and no longer marked */
6143 j_ptr->marked = OM_TOUCHED;
6145 /* Increase the weight */
6146 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6148 /* Count the items */
6151 /* Recalculate bonuses */
6152 p_ptr->update |= (PU_BONUS);
6154 /* Combine and Reorder pack */
6155 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6158 p_ptr->window |= (PW_INVEN);
6160 /* Return the slot */
6166 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6167 * Take off (some of) a non-cursed equipment item
6168 * @param item オブジェクトを外したい所持テーブルのID
6170 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6172 * Note that only one item at a time can be wielded per slot.\n
6173 * Note that taking off an item when "full" may cause that item\n
6174 * to fall to the ground.\n
6175 * Return the inventory slot into which the item is placed.\n
6177 INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
6188 char o_name[MAX_NLEN];
6191 /* Get the item to take off */
6192 o_ptr = &inventory[item];
6195 if (amt <= 0) return (-1);
6198 if (amt > o_ptr->number) amt = o_ptr->number;
6200 /* Get local object */
6203 /* Obtain a local object */
6204 object_copy(q_ptr, o_ptr);
6206 /* Modify quantity */
6207 q_ptr->number = amt;
6209 /* Describe the object */
6210 object_desc(o_name, q_ptr, 0);
6212 /* Took off weapon */
6213 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6214 object_is_melee_weapon(o_ptr))
6216 act = _("を装備からはずした", "You were wielding");
6220 else if (item == INVEN_BOW)
6222 act = _("を装備からはずした", "You were holding");
6225 /* Took off light */
6226 else if (item == INVEN_LITE)
6228 act = _("を光源からはずした", "You were holding");
6231 /* Took off something */
6234 act = _("を装備からはずした", "You were wearing");
6237 /* Modify, Optimize */
6238 inven_item_increase(item, -amt);
6239 inven_item_optimize(item);
6241 /* Carry the object */
6242 slot = inven_carry(q_ptr);
6246 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6248 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6258 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6259 * Drop (some of) a non-cursed inventory/equipment item
6260 * @param item 所持テーブルのID
6261 * @param amt 落としたい個数
6264 * The object will be dropped "near" the current location
6266 void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
6272 char o_name[MAX_NLEN];
6275 /* Access original object */
6276 o_ptr = &inventory[item];
6279 if (amt <= 0) return;
6282 if (amt > o_ptr->number) amt = o_ptr->number;
6285 /* Take off equipment */
6286 if (item >= INVEN_RARM)
6288 /* Take off first */
6289 item = inven_takeoff(item, amt);
6291 /* Access original object */
6292 o_ptr = &inventory[item];
6296 /* Get local object */
6299 /* Obtain local object */
6300 object_copy(q_ptr, o_ptr);
6302 /* Distribute charges of wands or rods */
6303 distribute_charges(o_ptr, q_ptr, amt);
6305 /* Modify quantity */
6306 q_ptr->number = amt;
6308 /* Describe local object */
6309 object_desc(o_name, q_ptr, 0);
6312 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6314 /* Drop it near the player */
6315 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6317 /* Modify, Describe, Optimize */
6318 inven_item_increase(item, -amt);
6319 inven_item_describe(item);
6320 inven_item_optimize(item);
6325 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6326 * Combine items in the pack
6329 * Note special handling of the "overflow" slot
6331 void combine_pack(void)
6336 bool flag = FALSE, combined;
6342 /* Combine the pack (backwards) */
6343 for (i = INVEN_PACK; i > 0; i--)
6346 o_ptr = &inventory[i];
6348 /* Skip empty items */
6349 if (!o_ptr->k_idx) continue;
6351 /* Scan the items above that item */
6352 for (j = 0; j < i; j++)
6357 j_ptr = &inventory[j];
6359 /* Skip empty items */
6360 if (!j_ptr->k_idx) continue;
6363 * Get maximum number of the stack if these
6364 * are similar, get zero otherwise.
6366 max_num = object_similar_part(j_ptr, o_ptr);
6368 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6369 if (max_num && j_ptr->number < max_num)
6371 if (o_ptr->number + j_ptr->number <= max_num)
6376 /* Add together the item counts */
6377 object_absorb(j_ptr, o_ptr);
6379 /* One object is gone */
6382 /* Slide everything down */
6383 for (k = i; k < INVEN_PACK; k++)
6385 /* Structure copy */
6386 inventory[k] = inventory[k+1];
6389 /* Erase the "final" slot */
6390 object_wipe(&inventory[k]);
6394 int old_num = o_ptr->number;
6395 int remain = j_ptr->number + o_ptr->number - max_num;
6397 o_ptr->number -= remain;
6399 /* Add together the item counts */
6400 object_absorb(j_ptr, o_ptr);
6402 o_ptr->number = remain;
6404 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6405 if (o_ptr->tval == TV_ROD)
6407 o_ptr->pval = o_ptr->pval * remain / old_num;
6408 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6411 /* Hack -- if wands are stacking, combine the charges. -LM- */
6412 if (o_ptr->tval == TV_WAND)
6414 o_ptr->pval = o_ptr->pval * remain / old_num;
6419 p_ptr->window |= (PW_INVEN);
6433 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6437 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6438 * Reorder items in the pack
6441 * Note special handling of the "overflow" slot
6443 void reorder_pack(void)
6453 /* Re-order the pack (forwards) */
6454 for (i = 0; i < INVEN_PACK; i++)
6456 /* Mega-Hack -- allow "proper" over-flow */
6457 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6460 o_ptr = &inventory[i];
6462 /* Skip empty slots */
6463 if (!o_ptr->k_idx) continue;
6465 /* Get the "value" of the item */
6466 o_value = object_value(o_ptr);
6468 /* Scan every occupied slot */
6469 for (j = 0; j < INVEN_PACK; j++)
6471 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6474 /* Never move down */
6475 if (j >= i) continue;
6480 /* Get local object */
6483 /* Save a copy of the moving item */
6484 object_copy(q_ptr, &inventory[i]);
6486 /* Slide the objects */
6487 for (k = i; k > j; k--)
6489 /* Slide the item */
6490 object_copy(&inventory[k], &inventory[k-1]);
6493 /* Insert the moving item */
6494 object_copy(&inventory[j], q_ptr);
6497 p_ptr->window |= (PW_INVEN);
6501 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6505 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6506 * Hack -- display an object kind in the current window
6507 * @param k_idx ベースアイテムの参照ID
6510 * Include list of usable spells for readible books
6512 void display_koff(IDX k_idx)
6519 REALM_IDX use_realm;
6521 char o_name[MAX_NLEN];
6524 /* Erase the window */
6525 for (y = 0; y < Term->hgt; y++)
6527 /* Erase the line */
6528 Term_erase(0, y, 255);
6534 /* Get local object */
6537 /* Prepare the object */
6538 object_prep(q_ptr, k_idx);
6541 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6543 /* Mention the object name */
6544 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6546 /* Access the item's sval */
6548 use_realm = tval2realm(q_ptr->tval);
6550 /* Warriors are illiterate */
6551 if (p_ptr->realm1 || p_ptr->realm2)
6553 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6557 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6558 if (!is_magic(use_realm)) return;
6559 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6562 /* Display spells in readible books */
6566 SPELL_IDX spells[64];
6568 /* Extract spells */
6569 for (spell = 0; spell < 32; spell++)
6571 /* Check for this spell */
6572 if (fake_spell_flags[sval] & (1L << spell))
6574 /* Collect this spell */
6575 spells[num++] = spell;
6580 print_spells(0, spells, num, 2, 0, use_realm);
6585 * @brief 警告を放つアイテムを選択する /
6586 * Choose one of items that have warning flag
6587 * Calculate spell damages
6590 object_type *choose_warning_item(void)
6593 int choices[INVEN_TOTAL - INVEN_RARM];
6596 /* Paranoia -- Player has no warning ability */
6597 if (!p_ptr->warning) return NULL;
6599 /* Search Inventory */
6600 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6602 u32b flgs[TR_FLAG_SIZE];
6603 object_type *o_ptr = &inventory[i];
6605 object_flags(o_ptr, flgs);
6606 if (have_flag(flgs, TR_WARNING))
6608 choices[number] = i;
6613 /* Choice one of them */
6614 return number ? &inventory[choices[randint0(number)]] : NULL;
6618 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6619 * Calculate spell damages
6620 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6621 * @param typ 効果属性のID
6623 * @param max 算出した最大ダメージを返すポインタ
6626 static void spell_damcalc(monster_type *m_ptr, int typ, HIT_POINT dam, int *max)
6628 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6629 int rlev = r_ptr->level;
6630 bool ignore_wraith_form = FALSE;
6632 /* Vulnerability, resistance and immunity */
6636 if (p_ptr->immune_elec)
6639 ignore_wraith_form = TRUE;
6643 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6644 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6645 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6646 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6647 if (IS_OPPOSE_ELEC())
6648 dam = (dam + 2) / 3;
6653 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6654 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6658 if (p_ptr->immune_acid)
6661 ignore_wraith_form = TRUE;
6665 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6666 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6667 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6668 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6674 if (p_ptr->immune_cold)
6677 ignore_wraith_form = TRUE;
6681 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6682 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6683 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6684 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6689 if (p_ptr->immune_fire)
6692 ignore_wraith_form = TRUE;
6696 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6697 if (prace_is_(RACE_ENT)) dam += dam / 3;
6698 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6699 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6700 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6705 ignore_wraith_form = TRUE;
6709 if (!p_ptr->blind &&
6710 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6711 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6714 ignore_wraith_form = TRUE;
6719 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6720 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6721 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6724 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6725 * "dam *= 2;" for later "dam /= 2"
6727 if (p_ptr->wraith_form) dam *= 2;
6731 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6734 ignore_wraith_form = TRUE;
6736 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6740 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6744 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6748 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6752 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6756 if (prace_is_(RACE_SPECTRE))
6759 ignore_wraith_form = TRUE;
6761 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6765 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6769 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6773 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6777 if (p_ptr->levitation) dam = (dam * 2) / 3;
6781 if (p_ptr->resist_shard) dam /= 2;
6785 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6786 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6790 if (p_ptr->mimic_form)
6792 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6795 ignore_wraith_form = TRUE;
6800 switch (p_ptr->prace)
6809 ignore_wraith_form = TRUE;
6816 if (p_ptr->align > 10) dam /= 2;
6817 else if (p_ptr->align < -10) dam *= 2;
6821 if (p_ptr->align > 10) dam *= 2;
6825 case GF_BRAIN_SMASH:
6826 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6829 ignore_wraith_form = TRUE;
6837 if (100 + rlev / 2 <= p_ptr->skill_sav)
6840 ignore_wraith_form = TRUE;
6845 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6848 ignore_wraith_form = TRUE;
6853 if (p_ptr->wraith_form && !ignore_wraith_form)
6859 if (dam > *max) *max = dam;
6863 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6864 * Calculate spell damages
6865 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6866 * @param typ 効果属性のID
6867 * @param m_idx 魔法を行使するモンスターのID
6868 * @param max 算出した最大ダメージを返すポインタ
6871 void spell_damcalc_by_spellnum(int spell_num, int typ, MONSTER_IDX m_idx, int *max)
6873 monster_type *m_ptr = &m_list[m_idx];
6874 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
6875 spell_damcalc(m_ptr, typ, dam, max);
6879 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
6880 * Calculate blow damages
6881 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
6882 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
6883 * @return 算出された最大ダメージを返す。
6885 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6887 int dam = blow_ptr->d_dice * blow_ptr->d_side;
6889 bool check_wraith_form = TRUE;
6891 if (blow_ptr->method != RBM_EXPLODE)
6893 int ac = p_ptr->ac + p_ptr->to_a;
6895 switch (blow_ptr->effect)
6899 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
6900 dam = MAX(dam, tmp_dam * 2);
6906 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
6910 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
6912 check_wraith_form = FALSE;
6916 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
6918 check_wraith_form = FALSE;
6922 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
6924 check_wraith_form = FALSE;
6928 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
6930 check_wraith_form = FALSE;
6935 check_wraith_form = FALSE;
6939 if (check_wraith_form && p_ptr->wraith_form)
6947 dam = (dam + 1) / 2;
6948 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
6956 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
6957 * Examine the grid (xx,yy) and warn the player if there are any danger
6958 * @param xx 危険性を調査するマスのX座標
6959 * @param yy 危険性を調査するマスのY座標
6960 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
6962 bool process_warning(int xx, int yy)
6966 char o_name[MAX_NLEN];
6968 #define WARNING_AWARE_RANGE 12
6970 static int old_damage = 0;
6972 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
6974 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
6977 monster_type *m_ptr;
6978 monster_race *r_ptr;
6980 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
6982 c_ptr = &cave[my][mx];
6984 if (!c_ptr->m_idx) continue;
6986 m_ptr = &m_list[c_ptr->m_idx];
6988 if (MON_CSLEEP(m_ptr)) continue;
6989 if (!is_hostile(m_ptr)) continue;
6991 r_ptr = &r_info[m_ptr->r_idx];
6993 /* Monster spells (only powerful ones)*/
6994 if (projectable(my, mx, yy, xx))
6996 u32b f4 = r_ptr->flags4;
6997 u32b f5 = r_ptr->a_ability_flags1;
6998 u32b f6 = r_ptr->a_ability_flags2;
7000 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7002 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7003 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7004 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7005 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7006 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7007 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7009 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7010 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7011 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7012 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7013 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7014 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7015 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7016 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7017 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7018 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7019 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7020 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7021 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7022 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7023 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7024 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7025 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7026 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7027 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7028 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7029 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7030 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7031 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7034 /* Monster melee attacks */
7035 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7037 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7041 for (m = 0; m < 4; m++)
7043 /* Skip non-attacks */
7044 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7046 /* Extract the attack info */
7047 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7048 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7050 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7054 /* Contribution from this monster */
7055 dam_max += dam_max0;
7059 /* Prevent excessive warning */
7060 if (dam_max > old_damage)
7062 old_damage = dam_max * 3 / 2;
7064 if (dam_max > p_ptr->chp / 2)
7066 object_type *o_ptr = choose_warning_item();
7069 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7071 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7072 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7075 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7078 else old_damage = old_damage / 2;
7080 c_ptr = &cave[yy][xx];
7081 if (((!easy_disarm && is_trap(c_ptr->feat))
7082 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7084 object_type *o_ptr = choose_warning_item();
7087 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7089 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7090 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7092 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7099 * エッセンス情報の構造体 / A structure for smithing
7102 int add; /* TR flag number or special essence id */
7103 cptr add_name; /* Name of this ability */
7104 ESSENCE_IDX type; /* Menu number */
7105 int essence; /* Index for carrying essences */
7106 int value; /* Needed value to add this ability */
7111 * エッセンス情報テーブル Smithing type data for Weapon smith
7114 static essence_type essence_info[] =
7116 {TR_STR, "腕力", 4, TR_STR, 20},
7117 {TR_INT, "知能", 4, TR_INT, 20},
7118 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7119 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7120 {TR_CON, "耐久力", 4, TR_CON, 20},
7121 {TR_CHR, "魅力", 4, TR_CHR, 20},
7122 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7123 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7124 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7125 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7126 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7127 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7128 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7129 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7130 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7131 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7132 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7133 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7134 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7135 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7136 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7137 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7138 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7139 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7140 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7141 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7142 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7143 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7144 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7145 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7146 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7147 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7148 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7149 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7150 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7151 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7152 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7153 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7154 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7155 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7156 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7157 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7158 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7159 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7160 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7161 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7162 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7163 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7164 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7165 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7166 {TR_SH_FIRE, "", 0, -2, 0},
7167 {TR_SH_ELEC, "", 0, -2, 0},
7168 {TR_SH_COLD, "", 0, -2, 0},
7169 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7170 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7171 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7172 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7173 {TR_LITE_2, "", 0, -2, 0},
7174 {TR_LITE_3, "", 0, -2, 0},
7175 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7176 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7177 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7178 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7179 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7181 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7182 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7183 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7184 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7185 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7186 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7187 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7188 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7189 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7190 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7191 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7192 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7193 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7194 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7195 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7196 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7197 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7198 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7200 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7201 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7202 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7203 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7204 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7205 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7206 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7207 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7209 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7210 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7211 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7212 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7213 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7214 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7215 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7216 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7217 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7218 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7219 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7220 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7222 {-1, NULL, 0, -1, 0}
7225 static essence_type essence_info[] =
7227 {TR_STR, "strength", 4, TR_STR, 20},
7228 {TR_INT, "intelligence", 4, TR_INT, 20},
7229 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7230 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7231 {TR_CON, "constitution", 4, TR_CON, 20},
7232 {TR_CHR, "charisma", 4, TR_CHR, 20},
7233 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7234 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7235 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7236 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7237 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7238 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7239 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7240 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7241 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7242 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7243 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7244 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7245 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7246 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7247 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7248 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7249 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7250 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7251 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7252 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7253 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7254 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7255 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7256 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7257 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7258 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7259 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7260 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7261 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7262 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7263 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7264 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7265 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7266 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7267 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7268 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7269 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7270 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7271 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7272 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7273 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7274 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7275 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7276 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7277 {TR_SH_FIRE, "", 0, -2, 0},
7278 {TR_SH_ELEC, "", 0, -2, 0},
7279 {TR_SH_COLD, "", 0, -2, 0},
7280 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7281 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7282 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7283 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7284 {TR_LITE_2, "", 0, -2, 0},
7285 {TR_LITE_3, "", 0, -2, 0},
7286 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7287 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7288 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7289 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7290 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7292 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7293 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7294 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7295 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7296 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7297 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7298 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7299 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7300 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7301 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7302 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7303 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7304 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7305 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7306 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7307 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7308 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7309 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7311 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7312 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7313 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7314 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7315 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7316 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7317 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7318 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7320 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7321 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7322 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7323 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7324 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7325 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7326 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7327 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7328 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7329 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7330 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7331 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7333 {-1, NULL, 0, -1, 0}
7339 * エッセンス名テーブル / Essense names for Weapon smith
7342 cptr essence_name[] =
7445 cptr essence_name[] =
7548 * @brief 所持しているエッセンス一覧を表示する
7551 static void display_essence(void)
7556 for (i = 1; i < 22; i++)
7560 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7561 "Essence Num Essence Num Essence Num "), 1, 8);
7562 for (i = 0; essence_name[i]; i++)
7564 if (!essence_name[i][0]) continue;
7565 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7568 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7578 static void drain_essence(void)
7580 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7584 bool observe = FALSE;
7585 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
7586 TIME_EFFECT old_timeout;
7587 BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7593 OBJECT_IDX next_o_idx;
7596 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7599 item_tester_hook = object_is_weapon_armour_ammo;
7600 item_tester_no_ryoute = TRUE;
7603 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7604 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7606 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7608 /* Get the item (in the pack) */
7611 o_ptr = &inventory[item];
7614 /* Get the item (on the floor) */
7617 o_ptr = &o_list[0 - item];
7620 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7622 char o_name[MAX_NLEN];
7623 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7624 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7627 p_ptr->energy_use = 100;
7629 object_flags(o_ptr, old_flgs);
7630 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7631 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7632 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7633 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7634 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7635 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7636 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7637 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7638 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7640 old_to_a = o_ptr->to_a;
7642 old_to_h = o_ptr->to_h;
7643 old_to_d = o_ptr->to_d;
7646 old_pval = o_ptr->pval;
7647 old_name2 = o_ptr->name2;
7648 old_timeout = o_ptr->timeout;
7649 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7650 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7651 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7652 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7653 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7654 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7655 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7656 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7657 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7658 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7659 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7660 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7661 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7662 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7663 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7664 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7665 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7666 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7667 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7671 next_o_idx = o_ptr->next_o_idx;
7672 marked = o_ptr->marked;
7673 weight = o_ptr->weight;
7674 number = o_ptr->number;
7676 object_prep(o_ptr, o_ptr->k_idx);
7680 o_ptr->next_o_idx=next_o_idx;
7681 o_ptr->marked=marked;
7682 o_ptr->number = number;
7683 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7684 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7685 o_ptr->ident |= (IDENT_MENTAL);
7686 object_aware(o_ptr);
7687 object_known(o_ptr);
7689 object_flags(o_ptr, new_flgs);
7691 for (i = 0; essence_info[i].add_name; i++)
7693 essence_type *es_ptr = &essence_info[i];
7694 PARAMETER_VALUE pval = 0;
7696 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7697 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7699 if (es_ptr->add < TR_FLAG_MAX &&
7700 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7701 have_flag(old_flgs, es_ptr->add))
7705 drain_value[es_ptr->essence] += 10 * pval;
7707 else if (es_ptr->essence != -2)
7709 drain_value[es_ptr->essence] += 10;
7711 else if (es_ptr->add == TR_SH_FIRE)
7713 drain_value[TR_BRAND_FIRE] += 10;
7714 drain_value[TR_RES_FIRE] += 10;
7716 else if (es_ptr->add == TR_SH_ELEC)
7718 drain_value[TR_BRAND_ELEC] += 10;
7719 drain_value[TR_RES_ELEC] += 10;
7721 else if (es_ptr->add == TR_SH_COLD)
7723 drain_value[TR_BRAND_COLD] += 10;
7724 drain_value[TR_RES_COLD] += 10;
7726 else if (es_ptr->add == TR_LITE_2)
7728 drain_value[TR_LITE_1] += 20;
7730 else if (es_ptr->add == TR_LITE_3)
7732 drain_value[TR_LITE_1] += 30;
7737 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7739 drain_value[TR_INT] += 5;
7740 drain_value[TR_WIS] += 5;
7742 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7744 drain_value[TR_BRAND_POIS] += 5;
7745 drain_value[TR_BRAND_ACID] += 5;
7746 drain_value[TR_BRAND_ELEC] += 5;
7747 drain_value[TR_BRAND_FIRE] += 5;
7748 drain_value[TR_BRAND_COLD] += 5;
7750 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7752 drain_value[TR_INT] += 10;
7754 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7756 drain_value[TR_STR] += 10;
7758 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7760 drain_value[TR_DEX] += 10;
7762 if (old_name2 == EGO_2WEAPON)
7764 drain_value[TR_DEX] += 20;
7766 if (object_is_weapon_ammo(o_ptr))
7768 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7770 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7772 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7773 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7774 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7775 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7777 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7779 drain_value[i] *= number;
7780 drain_value[i] = drain_value[i] * dec / 4;
7781 drain_value[i] = MAX(drain_value[i], 0);
7782 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7790 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7794 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7796 for (i = 0; essence_name[i]; i++)
7798 if (!essence_name[i][0]) continue;
7799 if (!drain_value[i]) continue;
7801 p_ptr->magic_num1[i] += drain_value[i];
7802 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7804 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7808 /* Apply autodestroy/inscription to the drained item */
7809 autopick_alter_item(item, TRUE);
7811 /* Combine the pack */
7812 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7815 p_ptr->window |= (PW_INVEN);
7819 * @brief 付加するエッセンスの大別を選択する
7820 * @return 選んだエッセンスの大別ID
7822 static COMMAND_CODE choose_essence(void)
7824 COMMAND_CODE mode = 0;
7826 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
7829 cptr menu_name[] = {
7839 cptr menu_name[] = {
7849 const COMMAND_CODE mode_max = 7;
7852 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7855 #endif /* ALLOW_REPEAT */
7864 for (i = 0; i < mode_max; i++)
7866 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
7867 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
7869 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
7870 prt("Choose from menu.", 0, 0);
7889 menu_line += mode_max - 1;
7898 if (menu_line > mode_max) menu_line -= mode_max;
7909 for (i = 0; i < mode_max; i++)
7910 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
7912 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
7918 if (isupper(choice)) choice = (char)tolower(choice);
7920 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
7921 mode = (int)choice - 'a' + 1;
7928 #endif /* ALLOW_REPEAT */
7933 * @brief エッセンスを実際に付加する
7934 * @param mode エッセンスの大別ID
7937 static void add_essence(ESSENCE_IDX mode)
7949 char o_name[MAX_NLEN];
7951 essence_type *es_ptr;
7952 bool able[22] = { 0 };
7954 int menu_line = (use_menu ? 1 : 0);
7956 for (i = 0; essence_info[i].add_name; i++)
7958 es_ptr = &essence_info[i];
7960 if (es_ptr->type != mode) continue;
7965 if (!repeat_pull(&i) || i<0 || i>=max_num)
7967 #endif /* ALLOW_REPEAT */
7970 /* Nothing chosen yet */
7976 /* Build a prompt */
7977 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
7978 if (use_menu) screen_save();
7980 /* Get a spell from the user */
7982 choice = (always_show_list || use_menu) ? ESCAPE:1;
7985 if( choice==ESCAPE ) choice = ' ';
7986 else if( !get_com(out_val, &choice, FALSE) )break;
7988 if (use_menu && choice != ' ')
8002 menu_line += (max_num-1);
8025 menu_line = max_num;
8039 if (menu_line > max_num) menu_line -= max_num;
8041 /* Request redraw */
8042 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8045 if (!redraw || use_menu)
8049 char dummy[80], dummy2[80];
8057 /* Save the screen */
8058 if (!use_menu) screen_save();
8060 for (y = 1; y < 24; y++)
8063 /* Print header(s) */
8065 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8068 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8071 for (ctr = 0; ctr < max_num; ctr++)
8073 es_ptr = &essence_info[num[ctr]];
8077 if (ctr == (menu_line-1))
8078 strcpy(dummy, _("》 ", "> "));
8079 else strcpy(dummy, " ");
8082 /* letter/number for power selection */
8085 sprintf(dummy, "%c) ",I2A(ctr));
8088 strcat(dummy, es_ptr->add_name);
8093 if (es_ptr->essence != -1)
8095 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8096 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8102 case ESSENCE_SH_FIRE:
8103 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8104 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8105 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8107 case ESSENCE_SH_ELEC:
8108 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8109 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8110 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8112 case ESSENCE_SH_COLD:
8113 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8114 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8115 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8117 case ESSENCE_RESISTANCE:
8118 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8119 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8120 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8121 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8122 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8124 case ESSENCE_SUSTAIN:
8125 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8126 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8127 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8128 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8129 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8134 if (!able[ctr]) col = TERM_RED;
8136 if (es_ptr->essence != -1)
8138 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8142 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8145 c_prt(col, dummy2, ctr+2, x);
8155 /* Restore the screen */
8166 ask = (isupper(choice));
8169 if (ask) choice = (char)tolower(choice);
8171 /* Extract request */
8172 i = (islower(choice) ? A2I(choice) : -1);
8175 /* Totally Illegal */
8176 if ((i < 0) || (i >= max_num) || !able[i])
8188 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8190 /* Belay that order */
8191 if (!get_check(tmp_val)) continue;
8198 /* Restore the screen */
8199 if (redraw) screen_load();
8206 #endif /* ALLOW_REPEAT */
8208 es_ptr = &essence_info[num[i]];
8210 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8211 item_tester_tval = TV_GLOVES;
8212 else if (mode == 1 || mode == 5)
8213 item_tester_hook = item_tester_hook_melee_ammo;
8214 else if (es_ptr->add == ESSENCE_ATTACK)
8215 item_tester_hook = object_allow_enchant_weapon;
8216 else if (es_ptr->add == ESSENCE_AC)
8217 item_tester_hook = object_is_armour;
8219 item_tester_hook = object_is_weapon_armour_ammo;
8220 item_tester_no_ryoute = TRUE;
8223 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8224 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8226 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8228 /* Get the item (in the pack) */
8231 o_ptr = &inventory[item];
8234 /* Get the item (on the floor) */
8237 o_ptr = &o_list[0 - item];
8240 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8242 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8246 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8248 use_essence = es_ptr->value;
8249 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8250 if (o_ptr->number > 1)
8252 use_essence *= o_ptr->number;
8253 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8256 if (es_ptr->essence != -1)
8258 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8260 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8263 if (is_pval_flag(es_ptr->add))
8265 if (o_ptr->pval < 0)
8267 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8270 else if (es_ptr->add == TR_BLOWS)
8272 if (o_ptr->pval > 1)
8274 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8278 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8280 else if (o_ptr->pval > 0)
8282 use_essence *= o_ptr->pval;
8283 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8289 PARAMETER_VALUE pval;
8290 PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8292 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8293 strcpy(tmp_val, "1");
8295 if (!get_string(tmp, tmp_val, 1)) return;
8296 pval = (PARAMETER_VALUE)atoi(tmp_val);
8297 if (pval > limit) pval = limit;
8298 else if (pval < 1) pval = 1;
8299 o_ptr->pval += pval;
8300 use_essence *= pval;
8301 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8304 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8306 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8310 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8317 strcpy(tmp_val, "1");
8318 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8319 val = atoi(tmp_val);
8320 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8321 else if (val < 1) val = 1;
8323 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8324 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8326 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8329 get_to_h = ((val+1)/2+randint0(val/2+1));
8330 get_to_d = ((val+1)/2+randint0(val/2+1));
8331 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8332 o_ptr->to_h += get_to_h;
8333 o_ptr->to_d += get_to_d;
8335 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8336 if (es_ptr->add == ESSENCE_ATTACK)
8338 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8340 msg_print(_("改良に失敗した。", "You failed to enchant."));
8341 p_ptr->energy_use = 100;
8346 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8347 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8350 else if (es_ptr->add == ESSENCE_AC)
8352 if (o_ptr->to_a >= p_ptr->lev/5+5)
8354 msg_print(_("改良に失敗した。", "You failed to enchant."));
8355 p_ptr->energy_use = 100;
8360 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8365 o_ptr->xtra3 = es_ptr->add + 1;
8370 bool success = TRUE;
8374 case ESSENCE_SH_FIRE:
8375 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8380 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8381 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8383 case ESSENCE_SH_ELEC:
8384 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8389 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8390 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8392 case ESSENCE_SH_COLD:
8393 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8398 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8399 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8401 case ESSENCE_RESISTANCE:
8402 case ESSENCE_SUSTAIN:
8403 if ((p_ptr->magic_num1[TR_RES_ACID] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8408 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8409 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8410 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8411 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8416 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8419 if (es_ptr->add == ESSENCE_SUSTAIN)
8421 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8422 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8423 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8424 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8428 o_ptr->xtra3 = es_ptr->add + 1;
8432 p_ptr->energy_use = 100;
8435 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8437 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8440 /* Combine the pack */
8441 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8444 p_ptr->window |= (PW_INVEN);
8451 static void erase_essence(void)
8456 char o_name[MAX_NLEN];
8457 BIT_FLAGS flgs[TR_FLAG_SIZE];
8459 item_tester_hook = object_is_smith;
8462 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8463 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8465 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8467 /* Get the item (in the pack) */
8470 o_ptr = &inventory[item];
8473 /* Get the item (on the floor) */
8476 o_ptr = &o_list[0 - item];
8479 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8480 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8482 p_ptr->energy_use = 100;
8484 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8486 o_ptr->to_h -= (o_ptr->xtra4>>8);
8487 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8489 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8490 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8493 object_flags(o_ptr, flgs);
8494 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8495 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8497 /* Combine the pack */
8498 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8501 p_ptr->window |= (PW_INVEN);
8505 * @brief 鍛冶コマンドのメインルーチン
8506 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8509 void do_cmd_kaji(bool only_browse)
8511 COMMAND_CODE mode = 0;
8514 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
8518 if (p_ptr->confused)
8520 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8525 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8530 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8536 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8538 #endif /* ALLOW_REPEAT */
8540 if (only_browse) screen_save();
8542 if (!only_browse) screen_save();
8548 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8549 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8550 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8551 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8552 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8553 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8555 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8556 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8557 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8558 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8559 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8560 prt(format("Choose command from menu."), 0, 0);
8587 if (menu_line > 5) menu_line -= 5;
8596 prt(" a) エッセンス一覧", 2, 14);
8597 prt(" b) エッセンス抽出", 3, 14);
8598 prt(" c) エッセンス消去", 4, 14);
8599 prt(" d) エッセンス付加", 5, 14);
8600 prt(" e) 武器/防具強化", 6, 14);
8601 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8603 prt(" a) List essences", 2, 14);
8604 prt(" b) Extract essence", 3, 14);
8605 prt(" c) Remove essence", 4, 14);
8606 prt(" d) Add essence", 5, 14);
8607 prt(" e) Enchant weapon/armor", 6, 14);
8608 if (!get_com("Command :", &choice, TRUE))
8645 /* Clear lines, position cursor (really should use strlen here) */
8646 Term_erase(14, 21, 255);
8647 Term_erase(14, 20, 255);
8648 Term_erase(14, 19, 255);
8649 Term_erase(14, 18, 255);
8650 Term_erase(14, 17, 255);
8651 Term_erase(14, 16, 255);
8653 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8654 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8656 prt(&temp[j], line, 15);
8661 if (!only_browse) screen_load();
8662 } while (only_browse);
8666 #endif /* ALLOW_REPEAT */
8670 case 1: display_essence();break;
8671 case 2: drain_essence();break;
8672 case 3: erase_essence();break;
8674 mode = choose_essence();
8679 case 5: add_essence(10);break;
8685 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8686 * Torches have special abilities when they are flaming.
8687 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8688 * @param flgs 特別に追加するフラグを返す参照ポインタ
8691 void torch_flags(object_type *o_ptr, u32b *flgs)
8693 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8695 if (o_ptr->xtra4 > 0)
8697 add_flag(flgs, TR_BRAND_FIRE);
8698 add_flag(flgs, TR_KILL_UNDEAD);
8699 add_flag(flgs, TR_THROW);
8705 * @brief 投擲時たいまつにダイスを与える。
8706 * Torches have special abilities when they are flaming.
8707 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8708 * @param dd 特別なダイス数を返す参照ポインタ
8709 * @param ds 特別なダイス面数を返す参照ポインタ
8712 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8714 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8716 if (o_ptr->xtra4 > 0)
8725 * @brief 投擲時命中したたいまつの寿命を縮める。
8726 * Torches have special abilities when they are flaming.
8727 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8730 void torch_lost_fuel(object_type *o_ptr)
8732 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8734 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8735 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;