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
16 static cptr const kaji_tips[5] =
19 "現在持っているエッセンスの一覧を表示する。",
20 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
21 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
22 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
23 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
25 "Display essences you have.",
26 "Extract essences from an item. The item become non magical.",
27 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
28 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
29 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
34 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
35 * @param o_idx 削除対象のオブジェクト構造体ポインタ
38 void excise_object_idx(int o_idx)
42 s16b this_o_idx, next_o_idx = 0;
48 j_ptr = &o_list[o_idx];
51 if (j_ptr->held_m_idx)
56 m_ptr = &m_list[j_ptr->held_m_idx];
58 /* Scan all objects in the grid */
59 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
64 o_ptr = &o_list[this_o_idx];
66 /* Acquire next object */
67 next_o_idx = o_ptr->next_o_idx;
70 if (this_o_idx == o_idx)
75 /* Remove from list */
76 m_ptr->hold_o_idx = next_o_idx;
85 k_ptr = &o_list[prev_o_idx];
87 /* Remove from list */
88 k_ptr->next_o_idx = next_o_idx;
91 /* Forget next pointer */
92 o_ptr->next_o_idx = 0;
99 prev_o_idx = this_o_idx;
114 /* Scan all objects in the grid */
115 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
120 o_ptr = &o_list[this_o_idx];
122 /* Acquire next object */
123 next_o_idx = o_ptr->next_o_idx;
126 if (this_o_idx == o_idx)
131 /* Remove from list */
132 c_ptr->o_idx = next_o_idx;
140 /* Previous object */
141 k_ptr = &o_list[prev_o_idx];
143 /* Remove from list */
144 k_ptr->next_o_idx = next_o_idx;
147 /* Forget next pointer */
148 o_ptr->next_o_idx = 0;
154 /* Save prev_o_idx */
155 prev_o_idx = this_o_idx;
161 * @brief オブジェクトを削除する /
162 * Delete a dungeon object
163 * @param o_idx 削除対象のオブジェクト構造体ポインタ
166 * Handle "stacks" of objects correctly.
168 void delete_object_idx(int o_idx)
173 excise_object_idx(o_idx);
176 j_ptr = &o_list[o_idx];
179 if (!(j_ptr->held_m_idx))
191 /* Wipe the object */
200 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
201 * Delete a dungeon object
202 * @param y 削除したフロアマスのY座標
203 * @param x 削除したフロアマスのX座標
206 void delete_object(int y, int x)
210 s16b this_o_idx, next_o_idx = 0;
213 /* Refuse "illegal" locations */
214 if (!in_bounds(y, x)) return;
220 /* Scan all objects in the grid */
221 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
226 o_ptr = &o_list[this_o_idx];
228 /* Acquire next object */
229 next_o_idx = o_ptr->next_o_idx;
231 /* Wipe the object */
238 /* Objects are gone */
247 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
248 * Move an object from index i1 to index i2 in the object list
249 * @param i1 整理したい配列の始点
250 * @param i2 整理したい配列の終点
253 static void compact_objects_aux(int i1, int i2)
263 if (i1 == i2) return;
267 for (i = 1; i < o_max; i++)
272 /* Skip "dead" objects */
273 if (!o_ptr->k_idx) continue;
275 /* Repair "next" pointers */
276 if (o_ptr->next_o_idx == i1)
279 o_ptr->next_o_idx = i2;
289 if (o_ptr->held_m_idx)
293 /* Acquire monster */
294 m_ptr = &m_list[o_ptr->held_m_idx];
297 if (m_ptr->hold_o_idx == i1)
300 m_ptr->hold_o_idx = i2;
309 /* Acquire location */
317 if (c_ptr->o_idx == i1)
326 o_list[i2] = o_list[i1];
334 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
335 * Compact and Reorder the object list.
336 * @param size 最低でも減らしたいオブジェクト数の水準
340 * This function can be very dangerous, use with caution!\n
342 * When actually "compacting" objects, we base the saving throw on a\n
343 * combination of object level, distance from player, and current\n
346 * After "compacting" (if needed), we "reorder" the objects into a more\n
347 * compact order, and we reset the allocation info, and the "live" array.\n
349 void compact_objects(int size)
351 int i, y, x, num, cnt;
352 int cur_lev, cur_dis, chance;
360 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
363 p_ptr->redraw |= (PR_MAP);
366 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
370 /* Compact at least 'size' objects */
371 for (num = 0, cnt = 1; num < size; cnt++)
373 /* Get more vicious each iteration */
376 /* Get closer each iteration */
377 cur_dis = 5 * (20 - cnt);
379 /* Examine the objects */
380 for (i = 1; i < o_max; i++)
384 /* Skip dead objects */
385 if (!o_ptr->k_idx) continue;
387 /* Hack -- High level objects start out "immune" */
388 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
391 if (o_ptr->held_m_idx)
395 /* Acquire monster */
396 m_ptr = &m_list[o_ptr->held_m_idx];
398 /* Get the location */
402 /* Monsters protect their objects */
403 if (randint0(100) < 90) continue;
409 /* Get the location */
414 /* Nearby objects start out "immune" */
415 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
420 /* Hack -- only compact artifacts in emergencies */
421 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
422 (cnt < 1000)) chance = 100;
424 /* Apply the saving throw */
425 if (randint0(100) < chance) continue;
427 /* Delete the object */
428 delete_object_idx(i);
436 /* Excise dead objects (backwards!) */
437 for (i = o_max - 1; i >= 1; i--)
441 /* Skip real objects */
442 if (o_ptr->k_idx) continue;
444 /* Move last object into open hole */
445 compact_objects_aux(o_max - 1, i);
447 /* Compress "o_max" */
454 * @brief グローバルオブジェクト配列を初期化する /
455 * Delete all the items when player leaves the level
456 * @note we do NOT visually reflect these (irrelevant) changes
458 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
459 * and the "m_ptr->next_o_idx" field for every monster, since
460 * we know we are clearing every object. Technically, we only
461 * clear those fields for grids/monsters containing objects,
462 * and we clear it once for every such object.
465 void wipe_o_list(void)
469 /* Delete the existing objects */
470 for (i = 1; i < o_max; i++)
472 object_type *o_ptr = &o_list[i];
474 /* Skip dead objects */
475 if (!o_ptr->k_idx) continue;
477 /* Mega-Hack -- preserve artifacts */
478 if (!character_dungeon || preserve_mode)
480 /* Hack -- Preserve unknown artifacts */
481 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
483 /* Mega-Hack -- Preserve the artifact */
484 a_info[o_ptr->name1].cur_num = 0;
489 if (o_ptr->held_m_idx)
494 m_ptr = &m_list[o_ptr->held_m_idx];
496 /* Hack -- see above */
497 m_ptr->hold_o_idx = 0;
505 /* Access location */
512 /* Hack -- see above */
516 /* Wipe the object */
529 * @brief グローバルオブジェクト配列から空きを取得する /
530 * Acquires and returns the index of a "free" object.
531 * @return 開いているオブジェクト要素のID
533 * This routine should almost never fail, but in case it does,
534 * we must be sure to handle "failure" of this routine.
541 /* Initial allocation */
542 if (o_max < max_o_idx)
547 /* Expand object array */
553 /* Use this object */
558 /* Recycle dead objects */
559 for (i = 1; i < o_max; i++)
566 /* Skip live objects */
567 if (o_ptr->k_idx) continue;
572 /* Use this object */
577 /* Warn the player (except during dungeon creation) */
578 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
586 * @brief オブジェクト生成テーブルに生成制約を加える /
587 * Apply a "object restriction function" to the "object allocation table"
589 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
591 static errr get_obj_num_prep(void)
596 alloc_entry *table = alloc_kind_table;
598 /* Scan the allocation table */
599 for (i = 0; i < alloc_kind_size; i++)
601 /* Accept objects which pass the restriction, if any */
602 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
604 /* Accept this object */
605 table[i].prob2 = table[i].prob1;
608 /* Do not use this object */
611 /* Decline this object */
622 * @brief オブジェクト生成テーブルからアイテムを取得する /
623 * Choose an object kind that seems "appropriate" to the given level
625 * @return 選ばれたオブジェクトベースID
627 * This function uses the "prob2" field of the "object allocation table",\n
628 * and various local information, to calculate the "prob3" field of the\n
629 * same table, which is then used to choose an "appropriate" object, in\n
630 * a relatively efficient manner.\n
632 * It is (slightly) more likely to acquire an object of the given level\n
633 * than one of a lower level. This is done by choosing several objects\n
634 * appropriate to the given level and keeping the "hardest" one.\n
636 * Note that if no objects are "appropriate", then this function will\n
637 * fail, and return zero, but this should *almost* never happen.\n
639 s16b get_obj_num(int level)
645 alloc_entry *table = alloc_kind_table;
647 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
650 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
652 /* Occasional "boost" */
653 if (one_in_(GREAT_OBJ))
655 /* What a bizarre calculation */
656 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
663 /* Process probabilities */
664 for (i = 0; i < alloc_kind_size; i++)
666 /* Objects are sorted by depth */
667 if (table[i].level > level) break;
672 /* Access the index */
673 k_idx = table[i].index;
675 /* Access the actual kind */
676 k_ptr = &k_info[k_idx];
678 /* Hack -- prevent embedded chests */
679 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
682 table[i].prob3 = table[i].prob2;
685 total += table[i].prob3;
688 /* No legal objects */
689 if (total <= 0) return (0);
693 value = randint0(total);
695 /* Find the object */
696 for (i = 0; i < alloc_kind_size; i++)
698 /* Found the entry */
699 if (value < table[i].prob3) break;
702 value = value - table[i].prob3;
709 /* Try for a "better" object once (50%) or twice (10%) */
716 value = randint0(total);
718 /* Find the object */
719 for (i = 0; i < alloc_kind_size; i++)
721 /* Found the entry */
722 if (value < table[i].prob3) break;
725 value = value - table[i].prob3;
728 /* Keep the "best" one */
729 if (table[i].level < table[j].level) i = j;
732 /* Try for a "better" object twice (10%) */
739 value = randint0(total);
741 /* Find the object */
742 for (i = 0; i < alloc_kind_size; i++)
744 /* Found the entry */
745 if (value < table[i].prob3) break;
748 value = value - table[i].prob3;
751 /* Keep the "best" one */
752 if (table[i].level < table[j].level) i = j;
757 return (table[i].index);
762 * @brief オブジェクトを鑑定済にする /
763 * Known is true when the "attributes" of an object are "known".
764 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
766 * These include tohit, todam, toac, cost, and pval (charges).\n
768 * Note that "knowing" an object gives you everything that an "awareness"\n
769 * gives you, and much more. In fact, the player is always "aware" of any\n
770 * item of which he has full "knowledge".\n
772 * But having full knowledge of, say, one "wand of wonder", does not, by\n
773 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
774 * It happens that most "identify" routines (including "buying from a shop")\n
775 * will make the player "aware" of the object as well as fully "know" it.\n
777 * This routine also removes any inscriptions generated by "feelings".\n
779 void object_known(object_type *o_ptr)
781 /* Remove "default inscriptions" */
782 o_ptr->feeling = FEEL_NONE;
784 /* Clear the "Felt" info */
785 o_ptr->ident &= ~(IDENT_SENSE);
787 /* Clear the "Empty" info */
788 o_ptr->ident &= ~(IDENT_EMPTY);
790 /* Now we know about the item */
791 o_ptr->ident |= (IDENT_KNOWN);
795 * @brief オブジェクトを*鑑定*済にする /
796 * The player is now aware of the effects of the given object.
797 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
800 void object_aware(object_type *o_ptr)
802 bool mihanmei = !object_is_aware(o_ptr);
804 /* Fully aware of the effects */
805 k_info[o_ptr->k_idx].aware = TRUE;
807 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
808 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
812 char o_name[MAX_NLEN];
815 object_copy(q_ptr, o_ptr);
818 object_desc(o_name, q_ptr, OD_NAME_ONLY);
820 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
826 * @brief オブジェクトを試行済にする /
827 * Something has been "sampled"
828 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
831 void object_tried(object_type *o_ptr)
833 /* Mark it as tried (even if "aware") */
834 k_info[o_ptr->k_idx].tried = TRUE;
839 * @brief 未鑑定なベースアイテムの基本価格を返す /
840 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
841 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
842 * @return オブジェクトの未鑑定価格
844 static s32b object_value_base(object_type *o_ptr)
846 /* Aware item -- use template cost */
847 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
849 /* Analyze the type */
854 case TV_FOOD: return (5L);
856 /* Un-aware Potions */
857 case TV_POTION: return (20L);
859 /* Un-aware Scrolls */
860 case TV_SCROLL: return (20L);
862 /* Un-aware Staffs */
863 case TV_STAFF: return (70L);
866 case TV_WAND: return (50L);
869 case TV_ROD: return (90L);
872 case TV_RING: return (45L);
874 /* Un-aware Amulets */
875 case TV_AMULET: return (45L);
877 /* Figurines, relative to monster level */
880 int level = r_info[o_ptr->pval].level;
881 if (level < 20) return level*50L;
882 else if (level < 30) return 1000+(level-20)*150L;
883 else if (level < 40) return 2500+(level-30)*350L;
884 else if (level < 50) return 6000+(level-40)*800L;
885 else return 14000+(level-50)*2000L;
889 if (!o_ptr->pval) return 1000L;
890 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
893 /* Paranoia -- Oops */
899 * @brief オブジェクトのフラグ類から価格を算出する /
900 * Return the value of the flags the object has...
901 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
902 * @param plusses フラグに与える価格の基本重み
903 * @return オブジェクトのフラグ価格
905 s32b flag_cost(object_type *o_ptr, int plusses)
908 u32b flgs[TR_FLAG_SIZE];
912 object_kind *k_ptr = &k_info[o_ptr->k_idx];
914 object_flags(o_ptr, flgs);
917 * Exclude fixed flags of the base item.
918 * pval bonuses of base item will be treated later.
920 for (i = 0; i < TR_FLAG_SIZE; i++)
921 flgs[i] &= ~(k_ptr->flags[i]);
923 /* Exclude fixed flags of the fixed artifact. */
924 if (object_is_fixed_artifact(o_ptr))
926 artifact_type *a_ptr = &a_info[o_ptr->name1];
928 for (i = 0; i < TR_FLAG_SIZE; i++)
929 flgs[i] &= ~(a_ptr->flags[i]);
932 /* Exclude fixed flags of the ego-item. */
933 else if (object_is_ego(o_ptr))
935 ego_item_type *e_ptr = &e_info[o_ptr->name2];
937 for (i = 0; i < TR_FLAG_SIZE; i++)
938 flgs[i] &= ~(e_ptr->flags[i]);
943 * Calucurate values of remaining flags
945 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
946 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
947 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
948 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
949 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
950 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
951 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
952 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
953 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
954 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
955 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
956 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
957 total += (10000 + (2500 * plusses));
958 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
959 total += (10000 + (2500 * plusses));
963 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
964 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
965 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
966 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
967 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
968 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
969 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
970 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
971 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
972 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
973 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
974 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
975 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
976 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
977 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
978 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
979 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
980 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
981 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
982 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
983 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
985 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
986 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
987 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
988 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
989 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
990 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
991 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
992 total += (tmp_cost * count);
994 if (have_flag(flgs, TR_SUST_STR)) total += 850;
995 if (have_flag(flgs, TR_SUST_INT)) total += 850;
996 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
997 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
998 if (have_flag(flgs, TR_SUST_CON)) total += 850;
999 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
1000 if (have_flag(flgs, TR_RIDING)) total += 0;
1001 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1002 if (have_flag(flgs, TR_THROW)) total += 5000;
1003 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1004 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1008 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1009 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1010 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1011 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1012 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1013 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1014 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1015 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1016 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1017 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1018 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1019 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1020 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1021 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1022 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1023 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1024 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1025 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1026 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1027 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1028 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1029 total += (tmp_cost * count);
1031 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1032 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1033 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1034 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1035 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1036 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1037 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1038 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1039 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1040 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1041 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1042 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1043 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1044 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1045 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1046 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1047 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1048 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1049 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1050 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1051 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1052 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1053 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1054 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1055 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1056 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1057 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1058 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1059 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1060 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1061 if (have_flag(flgs, TR_REGEN)) total += 2500;
1062 if (have_flag(flgs, TR_WARNING)) total += 2000;
1063 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1064 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1065 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1066 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1067 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1068 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1069 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1070 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1071 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1072 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1073 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1074 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1075 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1076 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1077 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1078 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1079 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1080 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1081 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1082 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1083 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1084 if (have_flag(flgs, TR_TELEPORT))
1086 if (object_is_cursed(o_ptr))
1091 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1092 if (have_flag(flgs, TR_BLESSED)) total += 750;
1093 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1094 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1095 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1096 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1097 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1099 /* Also, give some extra for activatable powers... */
1100 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1102 const activation_type* const act_ptr = find_activation_info(o_ptr);
1104 total += act_ptr->value;
1113 * @brief オブジェクトの真の価格を算出する /
1114 * Return the value of the flags the object has...
1115 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1116 * @return オブジェクトの本価格
1118 * Return the "real" price of a "known" item, not including discounts\n
1120 * Wand and staffs get cost for each charge\n
1122 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1124 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1126 * Missiles are only worth 5 gold per bonus point, since they\n
1127 * usually appear in groups of 20, and we want the player to get\n
1128 * the same amount of cash for any "equivalent" item. Note that\n
1129 * missiles never have any of the "pval" flags, and in fact, they\n
1130 * only have a few of the available flags, primarily of the "slay"\n
1131 * and "brand" and "ignore" variety.\n
1133 * Armor with a negative armor bonus is worthless.\n
1134 * Weapons with negative hit+damage bonuses are worthless.\n
1136 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1138 s32b object_value_real(object_type *o_ptr)
1142 u32b flgs[TR_FLAG_SIZE];
1144 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1147 /* Hack -- "worthless" items */
1148 if (!k_info[o_ptr->k_idx].cost) return (0L);
1151 value = k_info[o_ptr->k_idx].cost;
1153 /* Extract some flags */
1154 object_flags(o_ptr, flgs);
1157 if (object_is_fixed_artifact(o_ptr))
1159 artifact_type *a_ptr = &a_info[o_ptr->name1];
1161 /* Hack -- "worthless" artifacts */
1162 if (!a_ptr->cost) return (0L);
1164 /* Hack -- Use the artifact cost instead */
1165 value = a_ptr->cost;
1166 value += flag_cost(o_ptr, o_ptr->pval);
1168 /* Don't add pval bonuses etc. */
1173 else if (object_is_ego(o_ptr))
1175 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1177 /* Hack -- "worthless" ego-items */
1178 if (!e_ptr->cost) return (0L);
1180 /* Hack -- Reward the ego-item with a bonus */
1181 value += e_ptr->cost;
1182 value += flag_cost(o_ptr, o_ptr->pval);
1190 for (i = 0; i < TR_FLAG_SIZE; i++)
1191 if (o_ptr->art_flags[i]) flag = TRUE;
1193 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1196 /* Analyze pval bonus for normal object */
1197 switch (o_ptr->tval)
1220 if (!o_ptr->pval) break;
1222 /* Hack -- Negative "pval" is always bad */
1223 if (o_ptr->pval < 0) return (0L);
1225 /* Give credit for stat bonuses */
1226 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1227 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1228 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1229 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1230 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1231 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1233 /* Give credit for stealth and searching */
1234 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1235 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1236 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1238 /* Give credit for infra-vision and tunneling */
1239 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1240 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1242 /* Give credit for extra attacks */
1243 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1245 /* Give credit for speed bonus */
1246 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1252 /* Analyze the item */
1253 switch (o_ptr->tval)
1258 /* Pay extra for charges, depending on standard number of
1259 * charges. Handle new-style wands correctly. -LM-
1261 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1268 /* Pay extra for charges, depending on standard number of
1271 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1281 /* Hack -- negative bonuses are bad */
1282 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1284 /* Give credit for bonuses */
1285 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1302 /* Hack -- negative armor bonus */
1303 if (o_ptr->to_a < 0) return (0L);
1305 /* Give credit for bonuses */
1306 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1319 /* Hack -- negative hit/damage bonuses */
1320 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1322 /* Factor in the bonuses */
1323 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1325 /* Hack -- Factor in extra damage dice and sides */
1326 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1327 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1338 /* Hack -- negative hit/damage bonuses */
1339 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1341 /* Factor in the bonuses */
1342 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1344 /* Hack -- Factor in extra damage dice and sides */
1345 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1346 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1352 /* Figurines, relative to monster level */
1355 int level = r_info[o_ptr->pval].level;
1356 if (level < 20) value = level*50L;
1357 else if (level < 30) value = 1000+(level-20)*150L;
1358 else if (level < 40) value = 2500+(level-30)*350L;
1359 else if (level < 50) value = 6000+(level-40)*800L;
1360 else value = 14000+(level-50)*2000L;
1366 if (!o_ptr->pval) value = 1000L;
1367 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1373 if (!o_ptr->pval) value = 0L;
1378 /* Worthless object */
1379 if (value < 0) return 0L;
1381 /* Return the value */
1387 * @brief オブジェクト価格算出のメインルーチン /
1388 * Return the price of an item including plusses (and charges)
1389 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1390 * @return オブジェクトの判明している現価格
1392 * This function returns the "value" of the given item (qty one)\n
1394 * Never notice "unknown" bonuses or properties, including "curses",\n
1395 * since that would give the player information he did not have.\n
1397 * Note that discounted items stay discounted forever, even if\n
1398 * the discount is "forgotten" by the player via memory loss.\n
1400 s32b object_value(object_type *o_ptr)
1405 /* Unknown items -- acquire a base value */
1406 if (object_is_known(o_ptr))
1408 /* Broken items -- worthless */
1409 if (object_is_broken(o_ptr)) return (0L);
1411 /* Cursed items -- worthless */
1412 if (object_is_cursed(o_ptr)) return (0L);
1414 /* Real value (see above) */
1415 value = object_value_real(o_ptr);
1418 /* Known items -- acquire the actual value */
1421 /* Hack -- Felt broken items */
1422 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1424 /* Hack -- Felt cursed items */
1425 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1427 /* Base value (see above) */
1428 value = object_value_base(o_ptr);
1432 /* Apply discount (if any) */
1433 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1436 /* Return the final value */
1443 * @brief 破壊可能なアイテムかを返す /
1444 * Determines whether an object can be destroyed, and makes fake inscription.
1445 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1446 * @return オブジェクトが破壊可能ならばTRUEを返す
1448 bool can_player_destroy_object(object_type *o_ptr)
1450 /* Artifacts cannot be destroyed */
1451 if (!object_is_artifact(o_ptr)) return TRUE;
1453 /* If object is unidentified, makes fake inscription */
1454 if (!object_is_known(o_ptr))
1456 byte feel = FEEL_SPECIAL;
1458 /* Hack -- Handle icky artifacts */
1459 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1461 /* Hack -- inscribe the artifact */
1462 o_ptr->feeling = feel;
1464 /* We have "felt" it (again) */
1465 o_ptr->ident |= (IDENT_SENSE);
1467 /* Combine the pack */
1468 p_ptr->notice |= (PN_COMBINE);
1471 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1477 /* Identified artifact -- Nothing to do */
1483 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1484 * Distribute charges of rods or wands.
1485 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1486 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1487 * @param amt 分割したい回数量 number of items that are transfered
1490 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1491 * charges need to be allocated between the two stacks. If all the items\n
1492 * are being dropped, it makes for a neater message to leave the original\n
1493 * stack's pval alone. -LM-\n
1495 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1497 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1499 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1500 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1502 /* Hack -- Rods also need to have their timeouts distributed. The
1503 * dropped stack will accept all time remaining to charge up to its
1506 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1508 if (q_ptr->pval > o_ptr->timeout)
1509 q_ptr->timeout = o_ptr->timeout;
1511 q_ptr->timeout = q_ptr->pval;
1513 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1519 * @brief 魔法棒やロッドの使用回数を減らす /
1520 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1521 * @param amt 減らしたい回数量 number of items that are transfered
1524 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1525 * charges of the stack needs to be reduced, unless all the items are\n
1526 * being destroyed. -LM-\n
1528 void reduce_charges(object_type *o_ptr, int amt)
1530 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1531 (amt < o_ptr->number))
1533 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1538 * Determine if an item can "absorb" a second item
1540 * See "object_absorb()" for the actual "absorption" code.
1542 * If permitted, we allow staffs (if they are known to have equal charges
1543 * and both are either known or confirmed empty) and wands (if both are
1544 * either known or confirmed empty) and rods (in all cases) to combine.
1545 * Staffs will unstack (if necessary) when they are used, but wands and
1546 * rods will only unstack if one is dropped. -LM-
1548 * If permitted, we allow weapons/armor to stack, if fully "known".
1550 * Missiles will combine if both stacks have the same "known" status.
1551 * This is done to make unidentified stacks of missiles useful.
1553 * Food, potions, scrolls, and "easy know" items always stack.
1555 * Chests, and activatable items, never stack (for various reasons).
1559 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1561 #define MAX_STACK_SIZE 99
1565 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1566 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1567 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1568 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1569 * @return 重ね合わせ可能なアイテム数
1571 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1575 /* Default maximum number of stack */
1576 int max_num = MAX_STACK_SIZE;
1578 /* Require identical object types */
1579 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1582 /* Analyze the items */
1583 switch (o_ptr->tval)
1585 /* Chests and Statues*/
1596 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1597 if (o_ptr->pval != j_ptr->pval) return 0;
1601 /* Figurines and Corpses*/
1606 if (o_ptr->pval != j_ptr->pval) return 0;
1612 /* Food and Potions and Scrolls */
1624 /* Require either knowledge or known empty for both staffs. */
1625 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1626 !object_is_known(o_ptr)) ||
1627 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1628 !object_is_known(j_ptr))) return 0;
1630 /* Require identical charges, since staffs are bulky. */
1631 if (o_ptr->pval != j_ptr->pval) return 0;
1640 /* Require either knowledge or known empty for both wands. */
1641 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1642 !object_is_known(o_ptr)) ||
1643 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1644 !object_is_known(j_ptr))) return 0;
1646 /* Wand charges combine in O&ZAngband. */
1652 /* Staffs and Wands and Rods */
1655 /* Prevent overflaw of timeout */
1656 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1662 /* Weapons and Armor */
1678 /* Rings, Amulets, Lites */
1684 /* Require full knowledge of both items */
1685 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1695 /* Require identical knowledge of both items */
1696 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1697 if (o_ptr->feeling != j_ptr->feeling) return 0;
1699 /* Require identical "bonuses" */
1700 if (o_ptr->to_h != j_ptr->to_h) return 0;
1701 if (o_ptr->to_d != j_ptr->to_d) return 0;
1702 if (o_ptr->to_a != j_ptr->to_a) return 0;
1704 /* Require identical "pval" code */
1705 if (o_ptr->pval != j_ptr->pval) return 0;
1707 /* Artifacts never stack */
1708 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1710 /* Require identical "ego-item" names */
1711 if (o_ptr->name2 != j_ptr->name2) return 0;
1713 /* Require identical added essence */
1714 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1715 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1717 /* Hack -- Never stack "powerful" items */
1718 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1720 /* Hack -- Never stack recharging items */
1721 if (o_ptr->timeout || j_ptr->timeout) return 0;
1723 /* Require identical "values" */
1724 if (o_ptr->ac != j_ptr->ac) return 0;
1725 if (o_ptr->dd != j_ptr->dd) return 0;
1726 if (o_ptr->ds != j_ptr->ds) return 0;
1735 /* Require knowledge */
1736 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1744 /* Hack -- Identical art_flags! */
1745 for (i = 0; i < TR_FLAG_SIZE; i++)
1746 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1748 /* Hack -- Require identical "cursed" status */
1749 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1751 /* Hack -- Require identical "broken" status */
1752 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1755 /* Hack -- require semi-matching "inscriptions" */
1756 if (o_ptr->inscription && j_ptr->inscription &&
1757 (o_ptr->inscription != j_ptr->inscription))
1760 /* Hack -- normally require matching "inscriptions" */
1761 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1763 /* Hack -- normally require matching "discounts" */
1764 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1767 /* They match, so they must be similar */
1772 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1773 * Determine if an item can absorb a second item.
1774 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1775 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1776 * @return 重ね合わせ可能ならばTRUEを返す。
1778 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1780 int total = o_ptr->number + j_ptr->number;
1783 /* Are these objects similar? */
1784 max_num = object_similar_part(o_ptr, j_ptr);
1786 /* Return if not similar */
1787 if (!max_num) return FALSE;
1789 /* Maximal "stacking" limit */
1790 if (total > max_num) return (0);
1793 /* They match, so they must be similar */
1799 * @brief 両オブジェクトをスロットに重ね合わせる。
1800 * Allow one item to "absorb" another, assuming they are similar
1801 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1802 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1805 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1807 int max_num = object_similar_part(o_ptr, j_ptr);
1808 int total = o_ptr->number + j_ptr->number;
1809 int diff = (total > max_num) ? total - max_num : 0;
1811 /* Combine quantity, lose excess items */
1812 o_ptr->number = (total > max_num) ? max_num : total;
1814 /* Hack -- blend "known" status */
1815 if (object_is_known(j_ptr)) object_known(o_ptr);
1817 /* Hack -- clear "storebought" if only one has it */
1818 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1819 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1821 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1822 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1825 /* Hack -- blend "mental" status */
1826 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1828 /* Hack -- blend "inscriptions" */
1829 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1831 /* Hack -- blend "feelings" */
1832 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1834 /* Hack -- could average discounts XXX XXX XXX */
1835 /* Hack -- save largest discount XXX XXX XXX */
1836 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1838 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1839 if (o_ptr->tval == TV_ROD)
1841 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1842 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1845 /* Hack -- if wands are stacking, combine the charges. -LM- */
1846 if (o_ptr->tval == TV_WAND)
1848 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1854 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1855 * Find the index of the object_kind with the given tval and sval
1856 * @param tval 検索したいベースアイテムのtval
1857 * @param sval 検索したいベースアイテムのsval
1860 s16b lookup_kind(int tval, int sval)
1867 for (k = 1; k < max_k_idx; k++)
1869 object_kind *k_ptr = &k_info[k];
1871 /* Require correct tval */
1872 if (k_ptr->tval != tval) continue;
1875 if (k_ptr->sval == sval) return (k);
1877 /* Ignore illegal items */
1878 if (sval != SV_ANY) continue;
1880 /* Apply the randomizer */
1881 if (!one_in_(++num)) continue;
1883 /* Use this value */
1887 /* Return this choice */
1895 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1905 * @brief オブジェクトを初期化する
1906 * Wipe an object clean.
1907 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1910 void object_wipe(object_type *o_ptr)
1912 /* Wipe the structure */
1913 (void)WIPE(o_ptr, object_type);
1918 * @brief オブジェクトを複製する
1919 * Wipe an object clean.
1920 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1921 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1924 void object_copy(object_type *o_ptr, object_type *j_ptr)
1926 /* Copy the structure */
1927 (void)COPY(o_ptr, j_ptr, object_type);
1932 * @brief オブジェクト構造体にベースアイテムを作成する
1933 * Prepare an object based on an object kind.
1934 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1935 * @param k_idx 新たに作成したいベースアイテム情報のID
1938 void object_prep(object_type *o_ptr, int k_idx)
1940 object_kind *k_ptr = &k_info[k_idx];
1942 /* Clear the record */
1945 /* Save the kind index */
1946 o_ptr->k_idx = k_idx;
1948 /* Efficiency -- tval/sval */
1949 o_ptr->tval = k_ptr->tval;
1950 o_ptr->sval = k_ptr->sval;
1952 /* Default "pval" */
1953 o_ptr->pval = k_ptr->pval;
1955 /* Default number */
1958 /* Default weight */
1959 o_ptr->weight = k_ptr->weight;
1962 o_ptr->to_h = k_ptr->to_h;
1963 o_ptr->to_d = k_ptr->to_d;
1964 o_ptr->to_a = k_ptr->to_a;
1967 o_ptr->ac = k_ptr->ac;
1968 o_ptr->dd = k_ptr->dd;
1969 o_ptr->ds = k_ptr->ds;
1971 /* Default activation */
1972 if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
1974 /* Hack -- worthless items are always "broken" */
1975 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1977 /* Hack -- cursed items are always "cursed" */
1978 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1979 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1980 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1981 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1982 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1983 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1988 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
1989 * Help determine an "enchantment bonus" for an object.
1990 * @param max ボーナス値の限度
1991 * @param level ボーナス値に加味する基準生成階
1992 * @return 算出されたボーナス値
1994 * To avoid floating point but still provide a smooth distribution of bonuses,\n
1995 * we simply round the results of division in such a way as to "average" the\n
1996 * correct floating point value.\n
1998 * This function has been changed. It uses "randnor()" to choose values from\n
1999 * a normal distribution, whose mean moves from zero towards the max as the\n
2000 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2001 * and whose values are forced to lie between zero and the max, inclusive.\n
2003 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2004 * rare to get the "full" enchantment on an object, even a deep levels.\n
2006 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2008 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2010 * N 0 1 2 3 4 5 6 7 8 9 10\n
2011 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2012 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2013 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2014 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2015 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2016 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2017 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2018 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2019 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2020 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2021 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2022 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2023 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2024 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2025 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2026 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2027 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2028 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2030 s16b m_bonus(int max, int level)
2032 int bonus, stand, extra, value;
2035 /* Paranoia -- enforce maximal "level" */
2036 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2039 /* The "bonus" moves towards the max */
2040 bonus = ((max * level) / MAX_DEPTH);
2042 /* Hack -- determine fraction of error */
2043 extra = ((max * level) % MAX_DEPTH);
2045 /* Hack -- simulate floating point computations */
2046 if (randint0(MAX_DEPTH) < extra) bonus++;
2049 /* The "stand" is equal to one quarter of the max */
2052 /* Hack -- determine fraction of error */
2055 /* Hack -- simulate floating point computations */
2056 if (randint0(4) < extra) stand++;
2059 /* Choose an "interesting" value */
2060 value = randnor(bonus, stand);
2062 /* Enforce the minimum value */
2063 if (value < 0) return (0);
2065 /* Enforce the maximum value */
2066 if (value > max) return (max);
2074 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2075 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2078 static void object_mention(object_type *o_ptr)
2080 char o_name[MAX_NLEN];
2083 * @note アイテム名取得後アイテムの価値に応じたデバッグメッセージを出力する。
2084 * Get Describe and view, Artifact, Random Artifact, Ego-item, and Normal item.
2086 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
2088 if (object_is_fixed_artifact(o_ptr))
2090 msg_format(_("伝説のアイテム (%s)", "Artifact (%s)"), o_name);
2092 else if (o_ptr->art_name)
2094 msg_print(_("ランダム・アーティファクト", "Random artifact"));
2096 else if (object_is_ego(o_ptr))
2098 msg_format(_("名のあるアイテム (%s)", "Ego-item (%s)"), o_name);
2102 msg_format(_("アイテム (%s)", "Object (%s)"), o_name);
2107 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2108 * Mega-Hack -- Attempt to create one of the "Special Objects"
2109 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2110 * @return 生成に成功したらTRUEを返す。
2112 * We are only called from "make_object()", and we assume that\n
2113 * "apply_magic()" is called immediately after we return.\n
2115 * Note -- see "make_artifact()" and "apply_magic()"\n
2117 static bool make_artifact_special(object_type *o_ptr)
2122 /*! @note 地上ではキャンセルする / No artifacts in the town */
2123 if (!dun_level) return (FALSE);
2125 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2126 if (get_obj_num_hook) return (FALSE);
2128 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2129 for (i = 0; i < max_a_idx; i++)
2131 artifact_type *a_ptr = &a_info[i];
2133 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2134 if (!a_ptr->name) continue;
2136 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2137 if (a_ptr->cur_num) continue;
2138 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2139 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2141 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2142 * XXX XXX Enforce minimum "depth" (loosely) */
2143 if (a_ptr->level > object_level)
2145 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2146 int d = (a_ptr->level - object_level) * 2;
2147 if (!one_in_(d)) continue;
2150 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2151 if (!one_in_(a_ptr->rarity)) continue;
2153 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2154 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2155 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2156 if (k_info[k_idx].level > object_level)
2158 int d = (k_info[k_idx].level - object_level) * 5;
2159 if (!one_in_(d)) continue;
2162 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2163 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2164 object_prep(o_ptr, k_idx);
2167 random_artifact_resistance(o_ptr, a_ptr);
2171 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2177 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2178 * Mega-Hack -- Attempt to create one of the "Special Objects"
2179 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2180 * @return 生成に成功したらTRUEを返す。
2182 * Attempt to change an object into an artifact\n
2183 * This routine should only be called by "apply_magic()"\n
2184 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2186 static bool make_artifact(object_type *o_ptr)
2191 /* No artifacts in the town */
2192 if (!dun_level) return (FALSE);
2194 /* Paranoia -- no "plural" artifacts */
2195 if (o_ptr->number != 1) return (FALSE);
2197 /* Check the artifact list (skip the "specials") */
2198 for (i = 0; i < max_a_idx; i++)
2200 artifact_type *a_ptr = &a_info[i];
2202 /* Skip "empty" items */
2203 if (!a_ptr->name) continue;
2205 /* Cannot make an artifact twice */
2206 if (a_ptr->cur_num) continue;
2208 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2210 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2212 /* Must have the correct fields */
2213 if (a_ptr->tval != o_ptr->tval) continue;
2214 if (a_ptr->sval != o_ptr->sval) continue;
2216 /* XXX XXX Enforce minimum "depth" (loosely) */
2217 if (a_ptr->level > dun_level)
2219 /* Acquire the "out-of-depth factor" */
2220 int d = (a_ptr->level - dun_level) * 2;
2222 /* Roll for out-of-depth creation */
2223 if (!one_in_(d)) continue;
2226 /* We must make the "rarity roll" */
2227 if (!one_in_(a_ptr->rarity)) continue;
2229 /* Hack -- mark the item as an artifact */
2232 /* Hack: Some artifacts get random extra powers */
2233 random_artifact_resistance(o_ptr, a_ptr);
2245 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2246 * Choose random ego type
2247 * @param slot 取得したいエゴの装備部位
2248 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2249 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2251 static byte get_random_ego(byte slot, bool good)
2254 ego_item_type *e_ptr;
2258 for (i = 1; i < max_e_idx; i++)
2262 if (e_ptr->slot == slot
2263 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2266 total += (255 / e_ptr->rarity);
2270 value = randint1(total);
2272 for (i = 1; i < max_e_idx; i++)
2276 if (e_ptr->slot == slot
2277 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2280 value -= (255 / e_ptr->rarity);
2281 if (value <= 0L) break;
2289 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2290 * Apply magic to an item known to be a "weapon"
2291 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2292 * @param level 生成基準階
2293 * @param power 生成ランク
2296 * Hack -- note special base damage dice boosting\n
2297 * Hack -- note special processing for weapon/digger\n
2299 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2301 int tohit1 = randint1(5) + m_bonus(5, level);
2302 int todam1 = randint1(5) + m_bonus(5, level);
2304 int tohit2 = m_bonus(10, level);
2305 int todam2 = m_bonus(10, level);
2307 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2309 tohit2 = (tohit2+1)/2;
2310 todam2 = (todam2+1)/2;
2317 o_ptr->to_h += tohit1;
2318 o_ptr->to_d += todam1;
2324 o_ptr->to_h += tohit2;
2325 o_ptr->to_d += todam2;
2333 o_ptr->to_h -= tohit1;
2334 o_ptr->to_d -= todam1;
2339 /* Penalize again */
2340 o_ptr->to_h -= tohit2;
2341 o_ptr->to_d -= todam2;
2344 /* Cursed (if "bad") */
2345 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2348 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2351 switch (o_ptr->tval)
2358 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2359 create_artifact(o_ptr, FALSE);
2361 /* Special Ego-item */
2362 o_ptr->name2 = EGO_DIGGING;
2366 else if (power < -1)
2368 /* Hack -- Horrible digging bonus */
2369 o_ptr->pval = 0 - (5 + randint1(5));
2375 /* Hack -- Reverse digging bonus */
2376 o_ptr->pval = 0 - (o_ptr->pval);
2390 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2392 create_artifact(o_ptr, FALSE);
2397 /* Roll for an ego-item */
2398 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2399 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2401 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2403 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2408 switch (o_ptr->name2)
2411 if (one_in_(4) && (level > 40))
2412 add_flag(o_ptr->art_flags, TR_BLOWS);
2416 add_flag(o_ptr->art_flags, TR_RES_POIS);
2418 add_flag(o_ptr->art_flags, TR_WARNING);
2420 case EGO_KILL_DRAGON:
2422 add_flag(o_ptr->art_flags, TR_RES_POIS);
2426 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2428 case EGO_SLAYING_WEAPON:
2429 if (one_in_(3)) /* double damage */
2437 while (one_in_(o_ptr->dd));
2443 while (one_in_(o_ptr->ds));
2448 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2450 if (o_ptr->tval == TV_SWORD && one_in_(3))
2452 add_flag(o_ptr->art_flags, TR_VORPAL);
2457 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2463 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2465 add_flag(o_ptr->art_flags, TR_DEX);
2467 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2470 o_ptr->pval = m_bonus(5, level) + 1;
2472 case EGO_EARTHQUAKES:
2473 if (one_in_(3) && (level > 60))
2474 add_flag(o_ptr->art_flags, TR_BLOWS);
2476 o_ptr->pval = m_bonus(3, level);
2480 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2484 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2486 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2488 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2489 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2492 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2493 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2494 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2495 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2499 if (!o_ptr->art_name)
2501 /* Hack -- Super-charge the damage dice */
2502 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2504 /* Hack -- Lower the damage dice */
2505 if (o_ptr->dd > 9) o_ptr->dd = 9;
2510 else if (power < -1)
2512 /* Roll for ego-item */
2513 if (randint0(MAX_DEPTH) < level)
2517 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2518 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2524 switch (o_ptr->name2)
2527 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2528 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2530 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2531 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2532 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2533 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2534 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2535 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2549 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2551 create_artifact(o_ptr, FALSE);
2554 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2568 if (power > 2) /* power > 2 is debug only */
2570 create_artifact(o_ptr, FALSE);
2574 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2576 switch (o_ptr->name2)
2578 case EGO_SLAYING_BOLT:
2583 /* Hack -- super-charge the damage dice */
2584 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2586 /* Hack -- restrict the damage dice */
2587 if (o_ptr->dd > 9) o_ptr->dd = 9;
2591 else if (power < -1)
2593 /* Roll for ego-item */
2594 if (randint0(MAX_DEPTH) < level)
2596 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2606 * @brief ドラゴン装備にランダムな耐性を与える
2607 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2610 static void dragon_resist(object_type * o_ptr)
2615 one_dragon_ele_resistance(o_ptr);
2617 one_high_resistance(o_ptr);
2623 * @brief オブジェクトにランダムな強いESPを与える
2624 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2627 static bool add_esp_strong(object_type *o_ptr)
2629 bool nonliv = FALSE;
2631 switch (randint1(3))
2633 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2634 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2635 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2642 * @brief オブジェクトにランダムな弱いESPを与える
2643 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2644 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2647 static void add_esp_weak(object_type *o_ptr, bool extra)
2650 u32b weak_esp_list[] = {
2662 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2663 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2665 /* Add unduplicated weak esp flags randomly */
2666 for (i = 0; i < add_count; ++ i)
2668 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2670 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2671 weak_esp_list[choice] = weak_esp_list[i];
2677 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2678 * Apply magic to an item known to be "armor"
2679 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2680 * @param level 生成基準階
2681 * @param power 生成ランク
2684 * Hack -- note special processing for crown/helm\n
2685 * Hack -- note special processing for robe of permanence\n
2687 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2689 int toac1 = randint1(5) + m_bonus(5, level);
2691 int toac2 = m_bonus(10, level);
2697 o_ptr->to_a += toac1;
2703 o_ptr->to_a += toac2;
2711 o_ptr->to_a -= toac1;
2716 /* Penalize again */
2717 o_ptr->to_a -= toac2;
2720 /* Cursed (if "bad") */
2721 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2726 switch (o_ptr->tval)
2730 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2731 create_artifact(o_ptr, FALSE);
2733 /* Mention the item */
2734 if (cheat_peek) object_mention(o_ptr);
2745 /* Hack -- Try for "Robes of the Magi" */
2746 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2747 (o_ptr->sval == SV_ROBE) &&
2748 (randint0(100) < 15))
2752 o_ptr->name2 = EGO_YOIYAMI;
2753 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2754 o_ptr->sval = SV_YOIYAMI_ROBE;
2760 o_ptr->name2 = EGO_PERMANENCE;
2765 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2767 create_artifact(o_ptr, FALSE);
2773 bool okay_flag = TRUE;
2775 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2777 switch (o_ptr->name2)
2780 if (o_ptr->tval != TV_HARD_ARMOR)
2786 if (o_ptr->tval != TV_SOFT_ARMOR)
2798 switch (o_ptr->name2)
2800 case EGO_RESISTANCE:
2802 add_flag(o_ptr->art_flags, TR_RES_POIS);
2805 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2806 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2810 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2812 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2814 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2815 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2817 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2818 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2819 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2820 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2821 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2822 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2823 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2824 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2827 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2828 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2829 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2830 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2831 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2832 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2845 if (o_ptr->sval == SV_DRAGON_SHIELD)
2847 /* Mention the item */
2848 if (cheat_peek) object_mention(o_ptr);
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 /* Mention the item */
2898 if (cheat_peek) object_mention(o_ptr);
2899 dragon_resist(o_ptr);
2900 if (!one_in_(3)) break;
2904 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2906 create_artifact(o_ptr, FALSE);
2909 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2913 else if (power < -1)
2915 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2923 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2925 /* Mention the item */
2926 if (cheat_peek) object_mention(o_ptr);
2927 dragon_resist(o_ptr);
2928 if (!one_in_(3)) break;
2933 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2935 create_artifact(o_ptr, FALSE);
2938 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2940 switch (o_ptr->name2)
2942 case EGO_SLOW_DESCENT:
2945 one_high_resistance(o_ptr);
2951 else if (power < -1)
2953 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2964 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2966 create_artifact(o_ptr, FALSE);
2971 bool ok_flag = TRUE;
2972 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2974 switch (o_ptr->name2)
2977 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2978 else add_esp_weak(o_ptr, FALSE);
2982 case EGO_REGENERATION:
2983 case EGO_LORDLINESS:
2989 if (one_in_(2)) add_esp_strong(o_ptr);
2990 else add_esp_weak(o_ptr, FALSE);
2993 default:/* not existing crown (wisdom,lite, etc...) */
2997 break; /* while (1) */
3003 else if (power < -1)
3007 bool ok_flag = TRUE;
3008 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3010 switch (o_ptr->name2)
3012 case EGO_ANCIENT_CURSE:
3013 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3014 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3015 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3016 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3017 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3018 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3022 break; /* while (1) */
3031 if (o_ptr->sval == SV_DRAGON_HELM)
3033 /* Mention the item */
3034 if (cheat_peek) object_mention(o_ptr);
3035 dragon_resist(o_ptr);
3036 if (!one_in_(3)) break;
3042 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3044 create_artifact(o_ptr, FALSE);
3049 bool ok_flag = TRUE;
3050 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3052 switch (o_ptr->name2)
3054 case EGO_BRILLIANCE:
3056 case EGO_INFRAVISION:
3057 case EGO_H_PROTECTION:
3062 if (one_in_(2)) add_esp_strong(o_ptr);
3063 else add_esp_weak(o_ptr, FALSE);
3067 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3068 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3071 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3073 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3075 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3076 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3078 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3079 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3080 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3081 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3082 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3083 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3084 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3085 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3087 default:/* not existing helm (Magi, Might, etc...)*/
3091 break; /* while (1) */
3096 else if (power < -1)
3100 bool ok_flag = TRUE;
3101 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3103 switch (o_ptr->name2)
3105 case EGO_ANCIENT_CURSE:
3109 break; /* while (1) */
3120 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3122 create_artifact(o_ptr, FALSE);
3125 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3127 switch (o_ptr->name2)
3136 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3137 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3138 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3139 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3146 else if (power < -1)
3148 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3158 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3159 * Apply magic to an item known to be a "ring" or "amulet"
3160 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3161 * @param level 生成基準階
3162 * @param power 生成ランク
3165 * Hack -- note special "pval boost" code for ring of speed\n
3166 * Hack -- note that some items must be cursed (or blessed)\n
3168 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3170 /* Apply magic (good or bad) according to type */
3171 switch (o_ptr->tval)
3176 switch (o_ptr->sval)
3178 case SV_RING_ATTACKS:
3181 o_ptr->pval = m_bonus(2, level);
3182 if (one_in_(15)) o_ptr->pval++;
3183 if (o_ptr->pval < 1) o_ptr->pval = 1;
3189 o_ptr->ident |= (IDENT_BROKEN);
3192 o_ptr->curse_flags |= TRC_CURSED;
3195 o_ptr->pval = 0 - (o_ptr->pval);
3206 /* Strength, Constitution, Dexterity, Intelligence */
3212 o_ptr->pval = 1 + m_bonus(5, level);
3218 o_ptr->ident |= (IDENT_BROKEN);
3221 o_ptr->curse_flags |= TRC_CURSED;
3224 o_ptr->pval = 0 - (o_ptr->pval);
3230 /* Ring of Speed! */
3233 /* Base speed (1 to 10) */
3234 o_ptr->pval = randint1(5) + m_bonus(5, level);
3236 /* Super-charge the ring */
3237 while (randint0(100) < 50) o_ptr->pval++;
3243 o_ptr->ident |= (IDENT_BROKEN);
3246 o_ptr->curse_flags |= TRC_CURSED;
3249 o_ptr->pval = 0 - (o_ptr->pval);
3254 /* Mention the item */
3255 if (cheat_peek) object_mention(o_ptr);
3260 case SV_RING_LORDLY:
3264 one_lordly_high_resistance(o_ptr);
3268 /* Bonus to armor class */
3269 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3273 case SV_RING_WARNING:
3275 if (one_in_(3)) one_low_esp(o_ptr);
3280 case SV_RING_SEARCHING:
3282 /* Bonus to searching */
3283 o_ptr->pval = 1 + m_bonus(5, level);
3289 o_ptr->ident |= (IDENT_BROKEN);
3292 o_ptr->curse_flags |= TRC_CURSED;
3295 o_ptr->pval = 0 - (o_ptr->pval);
3301 /* Flames, Acid, Ice */
3302 case SV_RING_FLAMES:
3307 /* Bonus to armor class */
3308 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3312 /* Weakness, Stupidity */
3313 case SV_RING_WEAKNESS:
3314 case SV_RING_STUPIDITY:
3317 o_ptr->ident |= (IDENT_BROKEN);
3320 o_ptr->curse_flags |= TRC_CURSED;
3323 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3324 if (power > 0) power = 0 - power;
3329 /* WOE, Stupidity */
3333 o_ptr->ident |= (IDENT_BROKEN);
3336 o_ptr->curse_flags |= TRC_CURSED;
3339 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3340 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3341 if (power > 0) power = 0 - power;
3346 /* Ring of damage */
3347 case SV_RING_DAMAGE:
3349 /* Bonus to damage */
3350 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3356 o_ptr->ident |= (IDENT_BROKEN);
3359 o_ptr->curse_flags |= TRC_CURSED;
3362 o_ptr->to_d = 0 - o_ptr->to_d;
3368 /* Ring of Accuracy */
3369 case SV_RING_ACCURACY:
3372 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3378 o_ptr->ident |= (IDENT_BROKEN);
3381 o_ptr->curse_flags |= TRC_CURSED;
3384 o_ptr->to_h = 0 - o_ptr->to_h;
3390 /* Ring of Protection */
3391 case SV_RING_PROTECTION:
3393 /* Bonus to armor class */
3394 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3400 o_ptr->ident |= (IDENT_BROKEN);
3403 o_ptr->curse_flags |= TRC_CURSED;
3406 o_ptr->to_a = 0 - o_ptr->to_a;
3412 /* Ring of Slaying */
3413 case SV_RING_SLAYING:
3415 /* Bonus to damage and to hit */
3416 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3417 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3423 o_ptr->ident |= (IDENT_BROKEN);
3426 o_ptr->curse_flags |= TRC_CURSED;
3428 /* Reverse bonuses */
3429 o_ptr->to_h = 0 - o_ptr->to_h;
3430 o_ptr->to_d = 0 - o_ptr->to_d;
3436 case SV_RING_MUSCLE:
3438 o_ptr->pval = 1 + m_bonus(3, level);
3439 if (one_in_(4)) o_ptr->pval++;
3445 o_ptr->ident |= (IDENT_BROKEN);
3448 o_ptr->curse_flags |= TRC_CURSED;
3450 /* Reverse bonuses */
3451 o_ptr->pval = 0 - o_ptr->pval;
3456 case SV_RING_AGGRAVATION:
3459 o_ptr->ident |= (IDENT_BROKEN);
3462 o_ptr->curse_flags |= TRC_CURSED;
3464 if (power > 0) power = 0 - power;
3468 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3469 || (power > 2)) /* power > 2 is debug only */
3471 o_ptr->pval = MIN(o_ptr->pval, 4);
3472 /* Randart amulet */
3473 create_artifact(o_ptr, FALSE);
3475 else if ((power == 2) && one_in_(2))
3477 while(!o_ptr->name2)
3479 int tmp = m_bonus(10, level);
3480 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3481 switch(randint1(28))
3484 o_ptr->name2 = EGO_RING_THROW;
3487 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3488 o_ptr->name2 = EGO_RING_REGEN;
3491 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3492 o_ptr->name2 = EGO_RING_LITE;
3495 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3496 o_ptr->name2 = EGO_RING_TELEPORT;
3499 if (o_ptr->to_h) break;
3500 o_ptr->name2 = EGO_RING_TO_H;
3503 if (o_ptr->to_d) break;
3504 o_ptr->name2 = EGO_RING_TO_D;
3507 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3508 o_ptr->name2 = EGO_RING_SLAY;
3511 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3512 o_ptr->name2 = EGO_RING_WIZARD;
3515 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3516 o_ptr->name2 = EGO_RING_HERO;
3519 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3520 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3521 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3522 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3525 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3526 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;
3527 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3528 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3529 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3532 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3533 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;
3534 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3535 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3536 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3539 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3540 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;
3541 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3542 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3545 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3546 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;
3547 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3548 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3550 case 21: case 22: case 23: case 24: case 25: case 26:
3551 switch (o_ptr->sval)
3554 if (!one_in_(3)) break;
3555 o_ptr->name2 = EGO_RING_D_SPEED;
3557 case SV_RING_DAMAGE:
3558 case SV_RING_ACCURACY:
3559 case SV_RING_SLAYING:
3560 if (one_in_(2)) break;
3561 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3564 o_ptr->name2 = EGO_RING_BERSERKER;
3565 o_ptr->to_h -= 2+randint1(4);
3566 o_ptr->to_d += 2+randint1(4);
3569 case SV_RING_PROTECTION:
3570 o_ptr->name2 = EGO_RING_SUPER_AC;
3571 o_ptr->to_a += 7 + m_bonus(5, level);
3573 case SV_RING_RES_FEAR:
3574 o_ptr->name2 = EGO_RING_HERO;
3577 if (one_in_(2)) break;
3578 o_ptr->name2 = EGO_RING_HUNTER;
3580 case SV_RING_SEARCHING:
3581 o_ptr->name2 = EGO_RING_STEALTH;
3583 case SV_RING_TELEPORTATION:
3584 o_ptr->name2 = EGO_RING_TELE_AWAY;
3586 case SV_RING_RES_BLINDNESS:
3588 o_ptr->name2 = EGO_RING_RES_LITE;
3590 o_ptr->name2 = EGO_RING_RES_DARK;
3592 case SV_RING_LORDLY:
3593 if (!one_in_(20)) break;
3594 one_lordly_high_resistance(o_ptr);
3595 one_lordly_high_resistance(o_ptr);
3596 o_ptr->name2 = EGO_RING_TRUE;
3598 case SV_RING_SUSTAIN:
3599 if (!one_in_(4)) break;
3600 o_ptr->name2 = EGO_RING_RES_TIME;
3602 case SV_RING_FLAMES:
3603 if (!one_in_(2)) break;
3604 o_ptr->name2 = EGO_RING_DRAGON_F;
3607 if (!one_in_(2)) break;
3608 o_ptr->name2 = EGO_RING_DRAGON_C;
3610 case SV_RING_WARNING:
3611 if (!one_in_(2)) break;
3612 o_ptr->name2 = EGO_RING_M_DETECT;
3621 o_ptr->curse_flags = 0L;
3623 else if ((power == -2) && one_in_(2))
3625 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3626 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3627 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3628 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3629 o_ptr->art_flags[0] = 0;
3630 o_ptr->art_flags[1] = 0;
3631 while(!o_ptr->name2)
3633 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3637 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3638 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3641 o_ptr->name2 = EGO_RING_NO_MELEE;
3644 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3645 o_ptr->name2 = EGO_RING_AGGRAVATE;
3648 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3649 o_ptr->name2 = EGO_RING_TY_CURSE;
3652 o_ptr->name2 = EGO_RING_ALBINO;
3657 o_ptr->ident |= (IDENT_BROKEN);
3660 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3668 switch (o_ptr->sval)
3670 /* Amulet of wisdom/charisma */
3671 case SV_AMULET_INTELLIGENCE:
3672 case SV_AMULET_WISDOM:
3673 case SV_AMULET_CHARISMA:
3675 o_ptr->pval = 1 + m_bonus(5, level);
3681 o_ptr->ident |= (IDENT_BROKEN);
3684 o_ptr->curse_flags |= (TRC_CURSED);
3686 /* Reverse bonuses */
3687 o_ptr->pval = 0 - o_ptr->pval;
3693 /* Amulet of brilliance */
3694 case SV_AMULET_BRILLIANCE:
3696 o_ptr->pval = 1 + m_bonus(3, level);
3697 if (one_in_(4)) o_ptr->pval++;
3703 o_ptr->ident |= (IDENT_BROKEN);
3706 o_ptr->curse_flags |= (TRC_CURSED);
3708 /* Reverse bonuses */
3709 o_ptr->pval = 0 - o_ptr->pval;
3715 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3719 o_ptr->curse_flags |= (TRC_CURSED);
3724 case SV_AMULET_RESISTANCE:
3726 if (one_in_(5)) one_high_resistance(o_ptr);
3727 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3731 /* Amulet of searching */
3732 case SV_AMULET_SEARCHING:
3734 o_ptr->pval = randint1(2) + m_bonus(4, level);
3740 o_ptr->ident |= (IDENT_BROKEN);
3743 o_ptr->curse_flags |= (TRC_CURSED);
3745 /* Reverse bonuses */
3746 o_ptr->pval = 0 - (o_ptr->pval);
3752 /* Amulet of the Magi -- never cursed */
3753 case SV_AMULET_THE_MAGI:
3755 o_ptr->pval = randint1(5) + m_bonus(5, level);
3756 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3758 /* gain one low ESP */
3759 add_esp_weak(o_ptr, FALSE);
3761 /* Mention the item */
3762 if (cheat_peek) object_mention(o_ptr);
3767 /* Amulet of Doom -- always cursed */
3768 case SV_AMULET_DOOM:
3771 o_ptr->ident |= (IDENT_BROKEN);
3774 o_ptr->curse_flags |= (TRC_CURSED);
3777 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3778 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3779 if (power > 0) power = 0 - power;
3784 case SV_AMULET_MAGIC_MASTERY:
3786 o_ptr->pval = 1 + m_bonus(4, level);
3792 o_ptr->ident |= (IDENT_BROKEN);
3795 o_ptr->curse_flags |= (TRC_CURSED);
3797 /* Reverse bonuses */
3798 o_ptr->pval = 0 - o_ptr->pval;
3804 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3805 || (power > 2)) /* power > 2 is debug only */
3807 o_ptr->pval = MIN(o_ptr->pval, 4);
3808 /* Randart amulet */
3809 create_artifact(o_ptr, FALSE);
3811 else if ((power == 2) && one_in_(2))
3813 while(!o_ptr->name2)
3815 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3816 switch(randint1(21))
3819 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3820 o_ptr->name2 = EGO_AMU_SLOW_D;
3823 if (o_ptr->pval) break;
3824 o_ptr->name2 = EGO_AMU_INFRA;
3827 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3828 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3831 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3832 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3835 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3836 o_ptr->name2 = EGO_AMU_LEVITATION;
3838 case 10: case 11: case 21:
3839 o_ptr->name2 = EGO_AMU_AC;
3842 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3843 if (m_bonus(10, level) > 8)
3844 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3846 o_ptr->name2 = EGO_AMU_RES_FIRE;
3849 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3850 if (m_bonus(10, level) > 8)
3851 o_ptr->name2 = EGO_AMU_RES_COLD_;
3853 o_ptr->name2 = EGO_AMU_RES_COLD;
3856 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3857 if (m_bonus(10, level) > 8)
3858 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3860 o_ptr->name2 = EGO_AMU_RES_ELEC;
3863 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3864 if (m_bonus(10, level) > 8)
3865 o_ptr->name2 = EGO_AMU_RES_ACID_;
3867 o_ptr->name2 = EGO_AMU_RES_ACID;
3869 case 16: case 17: case 18: case 19: case 20:
3870 switch (o_ptr->sval)
3872 case SV_AMULET_TELEPORT:
3873 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3874 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3875 else o_ptr->name2 = EGO_AMU_TELEPORT;
3877 case SV_AMULET_RESIST_ACID:
3878 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3880 case SV_AMULET_SEARCHING:
3881 o_ptr->name2 = EGO_AMU_STEALTH;
3883 case SV_AMULET_BRILLIANCE:
3884 if (!one_in_(3)) break;
3885 o_ptr->name2 = EGO_AMU_IDENT;
3887 case SV_AMULET_CHARISMA:
3888 if (!one_in_(3)) break;
3889 o_ptr->name2 = EGO_AMU_CHARM;
3891 case SV_AMULET_THE_MAGI:
3892 if (one_in_(2)) break;
3893 o_ptr->name2 = EGO_AMU_GREAT;
3895 case SV_AMULET_RESISTANCE:
3896 if (!one_in_(5)) break;
3897 o_ptr->name2 = EGO_AMU_DEFENDER;
3899 case SV_AMULET_TELEPATHY:
3900 if (!one_in_(3)) break;
3901 o_ptr->name2 = EGO_AMU_DETECTION;
3907 o_ptr->curse_flags = 0L;
3909 else if ((power == -2) && one_in_(2))
3911 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3912 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3913 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3914 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3915 o_ptr->art_flags[0] = 0;
3916 o_ptr->art_flags[1] = 0;
3917 while(!o_ptr->name2)
3919 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3923 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3924 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3927 o_ptr->name2 = EGO_AMU_FOOL;
3930 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3931 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3934 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3935 o_ptr->name2 = EGO_AMU_TY_CURSE;
3938 o_ptr->name2 = EGO_AMU_NAIVETY;
3943 o_ptr->ident |= (IDENT_BROKEN);
3946 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3954 * @brief モンスターが人形のベースにできるかを返す
3955 * @param r_idx チェックしたいモンスター種族のID
3956 * @return 人形にできるならTRUEを返す
3958 static bool item_monster_okay(int r_idx)
3960 monster_race *r_ptr = &r_info[r_idx];
3963 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3964 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3965 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3966 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3967 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3968 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3976 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3977 * Apply magic to an item known to be "boring"
3978 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3979 * @param level 生成基準階
3980 * @param power 生成ランク
3983 * Hack -- note the special code for various items
3985 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3987 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3992 /* Apply magic (good or bad) according to type */
3993 switch (o_ptr->tval)
4002 o_ptr->ident |= (IDENT_BROKEN);
4005 o_ptr->curse_flags |= (TRC_CURSED);
4012 o_ptr->xtra4 = o_ptr->pval;
4018 /* Hack -- Torches -- random fuel */
4019 if (o_ptr->sval == SV_LITE_TORCH)
4021 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4025 /* Hack -- Lanterns -- random fuel */
4026 if (o_ptr->sval == SV_LITE_LANTERN)
4028 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4032 if (power > 2) /* power > 2 is debug only */
4034 create_artifact(o_ptr, FALSE);
4036 else if ((power == 2) || ((power == 1) && one_in_(3)))
4038 while (!o_ptr->name2)
4042 bool okay_flag = TRUE;
4044 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4046 switch (o_ptr->name2)
4049 if (o_ptr->sval == SV_LITE_FEANOR)
4057 else if (power == -2)
4059 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4061 switch (o_ptr->name2)
4063 case EGO_LITE_DARKNESS:
4066 if (o_ptr->sval == SV_LITE_TORCH)
4068 add_flag(o_ptr->art_flags, TR_LITE_M1);
4070 else if (o_ptr->sval == SV_LITE_LANTERN)
4072 add_flag(o_ptr->art_flags, TR_LITE_M2);
4074 else if (o_ptr->sval == SV_LITE_FEANOR)
4076 add_flag(o_ptr->art_flags, TR_LITE_M3);
4088 /* The wand or staff gets a number of initial charges equal
4089 * to between 1/2 (+1) and the full object kind's pval. -LM-
4091 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4097 /* Transfer the pval. -LM- */
4098 o_ptr->pval = k_ptr->pval;
4105 object_aware(o_ptr);
4106 object_known(o_ptr);
4115 monster_race *r_ptr;
4117 /* Pick a random non-unique monster race */
4120 i = randint1(max_r_idx - 1);
4122 if (!item_monster_okay(i)) continue;
4123 if (i == MON_TSUCHINOKO) continue;
4127 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4129 /* Ignore dead monsters */
4130 if (!r_ptr->rarity) continue;
4132 /* Ignore uncommon monsters */
4133 if (r_ptr->rarity > 100) continue;
4135 /* Prefer less out-of-depth monsters */
4136 if (randint0(check)) continue;
4143 /* Some figurines are cursed */
4144 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4148 msg_format(_("%sの人形, 深さ +%d%s", "Figurine of %s, depth +%d%s"),
4149 r_name + r_ptr->name, check - 1,
4150 !object_is_cursed(o_ptr) ? "" : " {cursed}");
4163 monster_race *r_ptr;
4165 if (o_ptr->sval == SV_SKELETON)
4167 match = RF9_DROP_SKELETON;
4169 else if (o_ptr->sval == SV_CORPSE)
4171 match = RF9_DROP_CORPSE;
4174 /* Hack -- Remove the monster restriction */
4175 get_mon_num_prep(item_monster_okay, NULL);
4177 /* Pick a random non-unique monster race */
4180 i = get_mon_num(dun_level);
4184 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4186 /* Ignore dead monsters */
4187 if (!r_ptr->rarity) continue;
4189 /* Ignore corpseless monsters */
4190 if (!(r_ptr->flags9 & match)) continue;
4192 /* Prefer less out-of-depth monsters */
4193 if (randint0(check)) continue;
4202 msg_format(_("%sの死体, 深さ +%d", "Corpse of %s, depth +%d"),
4203 r_name + r_ptr->name, check - 1);
4206 object_aware(o_ptr);
4207 object_known(o_ptr);
4215 monster_race *r_ptr;
4217 /* Pick a random monster race */
4220 i = randint1(max_r_idx - 1);
4224 /* Ignore dead monsters */
4225 if (!r_ptr->rarity) continue;
4234 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4236 object_aware(o_ptr);
4237 object_known(o_ptr);
4244 byte obj_level = k_info[o_ptr->k_idx].level;
4246 /* Hack -- skip ruined chests */
4247 if (obj_level <= 0) break;
4249 /* Hack -- pick a "difficulty" */
4250 o_ptr->pval = randint1(obj_level);
4251 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4253 o_ptr->xtra3 = dun_level + 5;
4255 /* Never exceed "difficulty" of 55 to 59 */
4256 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4264 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4265 * Complete the "creation" of an object by applying "magic" to the item
4266 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4268 * @param mode 生成オプション
4271 * This includes not only rolling for random bonuses, but also putting the\n
4272 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4273 * staffs, giving fuel to lites, and placing traps on chests.\n
4275 * In particular, note that "Instant Artifacts", if "created" by an external\n
4276 * routine, must pass through this function to complete the actual creation.\n
4278 * The base "chance" of the item being "good" increases with the "level"\n
4279 * parameter, which is usually derived from the dungeon level, being equal\n
4280 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4281 * the object is guaranteed to be "good". If an object is "good", then\n
4282 * the chance that the object will be "great" (ego-item or artifact), also\n
4283 * increases with the "level", being equal to half the level, plus 5, up to\n
4284 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4285 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4287 * If the object is not "good", there is a chance it will be "cursed", and\n
4288 * if it is "cursed", there is a chance it will be "broken". These chances\n
4289 * are related to the "good" / "great" chances above.\n
4291 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4292 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4294 * If "okay" is true, and the object is going to be "great", then there is\n
4295 * a chance that an artifact will be created. This is true even if both the\n
4296 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4297 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4299 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4301 int i, rolls, f1, f2, power;
4303 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4305 /* Maximum "level" for various things */
4306 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4308 /* Base chance of being "good" */
4311 /* Maximal chance of being "good" */
4312 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4314 /* Base chance of being "great" */
4317 /* Maximal chance of being "great" */
4318 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4319 f2 = d_info[dungeon_type].obj_great;
4321 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4326 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4335 /* Roll for "good" */
4336 if ((mode & AM_GOOD) || magik(f1))
4341 /* Roll for "great" */
4342 if ((mode & AM_GREAT) || magik(f2))
4346 /* Roll for "special" */
4347 if (mode & AM_SPECIAL) power = 3;
4351 /* Roll for "cursed" */
4354 /* Assume "cursed" */
4357 /* Roll for "broken" */
4358 if (magik(f2)) power = -2;
4362 if (mode & AM_CURSED)
4364 /* Assume 'cursed' */
4369 /* Everything else gets more badly cursed */
4376 /* Assume no rolls */
4379 /* Get one roll if excellent */
4380 if (power >= 2) rolls = 1;
4382 /* Hack -- Get four rolls if forced great or special */
4383 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4385 /* Hack -- Get no rolls if not allowed */
4386 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4388 /* Roll for artifacts if allowed */
4389 for (i = 0; i < rolls; i++)
4391 /* Roll for an artifact */
4392 if (make_artifact(o_ptr)) break;
4393 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4395 if (make_artifact(o_ptr)) break;
4400 /* Hack -- analyze artifacts */
4401 if (object_is_fixed_artifact(o_ptr))
4403 artifact_type *a_ptr = &a_info[o_ptr->name1];
4405 /* Hack -- Mark the artifact as "created" */
4408 /* Hack -- Memorize location of artifact in saved floors */
4409 if (character_dungeon)
4410 a_ptr->floor_id = p_ptr->floor_id;
4412 /* Extract the other fields */
4413 o_ptr->pval = a_ptr->pval;
4414 o_ptr->ac = a_ptr->ac;
4415 o_ptr->dd = a_ptr->dd;
4416 o_ptr->ds = a_ptr->ds;
4417 o_ptr->to_a = a_ptr->to_a;
4418 o_ptr->to_h = a_ptr->to_h;
4419 o_ptr->to_d = a_ptr->to_d;
4420 o_ptr->weight = a_ptr->weight;
4421 o_ptr->xtra2 = a_ptr->act_idx;
4423 if (o_ptr->name1 == ART_MILIM)
4425 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4431 /* Hack -- extract the "broken" flag */
4432 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4434 /* Hack -- extract the "cursed" flag */
4435 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4436 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4437 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4438 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4439 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4440 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4443 /* Cheat -- peek at the item */
4444 if (cheat_peek) object_mention(o_ptr);
4452 switch (o_ptr->tval)
4461 if (power) a_m_aux_1(o_ptr, lev, power);
4467 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4473 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4487 /* Elven Cloak and Black Clothes ... */
4488 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4489 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4490 o_ptr->pval = randint1(4);
4494 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4495 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4496 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4497 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4498 a_m_aux_2(o_ptr, lev, power);
4500 if (power) a_m_aux_2(o_ptr, lev, power);
4508 if (!power && (randint0(100) < 50)) power = -1;
4509 a_m_aux_3(o_ptr, lev, power);
4515 a_m_aux_4(o_ptr, lev, power);
4520 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4521 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4522 (p_ptr->pseikaku == SEIKAKU_SEXY))
4525 add_flag(o_ptr->art_flags, TR_STR);
4526 add_flag(o_ptr->art_flags, TR_INT);
4527 add_flag(o_ptr->art_flags, TR_WIS);
4528 add_flag(o_ptr->art_flags, TR_DEX);
4529 add_flag(o_ptr->art_flags, TR_CON);
4530 add_flag(o_ptr->art_flags, TR_CHR);
4533 /* Hack -- analyze ego-items */
4534 if (object_is_ego(o_ptr))
4536 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4538 /* Hack -- acquire "broken" flag */
4539 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4541 /* Hack -- acquire "cursed" flag */
4542 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4543 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4544 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4545 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4546 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4547 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4549 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4550 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4551 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4552 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4553 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4554 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4555 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4556 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4562 while (one_in_(o_ptr->dd));
4564 if (o_ptr->dd > 9) o_ptr->dd = 9;
4567 /* Hack -- apply activatin index if needed */
4568 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4570 /* Hack -- apply extra penalties if needed */
4571 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4573 /* Hack -- obtain bonuses */
4574 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4575 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4576 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4578 /* Hack -- obtain pval */
4579 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4582 /* Hack -- apply extra bonuses if needed */
4585 /* Hack -- obtain bonuses */
4586 if (e_ptr->max_to_h)
4588 if (e_ptr->max_to_h > 127)
4589 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4590 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4592 if (e_ptr->max_to_d)
4594 if (e_ptr->max_to_d > 127)
4595 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4596 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4598 if (e_ptr->max_to_a)
4600 if (e_ptr->max_to_a > 127)
4601 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4602 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4605 /* Accuracy ego must have high to_h */
4606 if(o_ptr->name2 == EGO_ACCURACY)
4608 while(o_ptr->to_h < o_ptr->to_d + 10)
4613 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4616 /* Accuracy ego must have high to_h */
4617 if(o_ptr->name2 == EGO_VELOCITY)
4619 while(o_ptr->to_d < o_ptr->to_h + 10)
4624 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4627 /* Protection ego must have high to_a */
4628 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4630 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4633 /* Hack -- obtain pval */
4634 if (e_ptr->max_pval)
4636 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4639 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4641 else if (o_ptr->name2 == EGO_DEMON)
4643 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4645 o_ptr->pval += randint1(2);
4649 o_ptr->pval += randint1(e_ptr->max_pval);
4652 else if (o_ptr->name2 == EGO_ATTACKS)
4654 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4655 if (o_ptr->pval > 3) o_ptr->pval = 3;
4656 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4657 o_ptr->pval += randint1(2);
4659 else if (o_ptr->name2 == EGO_BAT)
4661 o_ptr->pval = randint1(e_ptr->max_pval);
4662 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4664 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4666 o_ptr->pval = randint1(e_ptr->max_pval);
4670 o_ptr->pval += randint1(e_ptr->max_pval);
4675 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4677 o_ptr->pval = randint1(o_ptr->pval);
4679 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4683 /* Cheat -- describe the item */
4684 if (cheat_peek) object_mention(o_ptr);
4690 /* Examine real objects */
4693 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4695 /* Hack -- acquire "broken" flag */
4696 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4698 /* Hack -- acquire "cursed" flag */
4699 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4700 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4701 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4702 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4703 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4704 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4710 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4711 * Hack -- determine if a template is "good"
4712 * @param k_idx 判定したいベースアイテムのID
4713 * @return ベースアイテムが上質ならばTRUEを返す。
4715 static bool kind_is_good(int k_idx)
4717 object_kind *k_ptr = &k_info[k_idx];
4719 /* Analyze the item type */
4720 switch (k_ptr->tval)
4722 /* Armor -- Good unless damaged */
4733 if (k_ptr->to_a < 0) return (FALSE);
4737 /* Weapons -- Good unless damaged */
4744 if (k_ptr->to_h < 0) return (FALSE);
4745 if (k_ptr->to_d < 0) return (FALSE);
4749 /* Ammo -- Arrows/Bolts are good */
4756 /* Books -- High level books are good (except Arcane books) */
4758 case TV_SORCERY_BOOK:
4759 case TV_NATURE_BOOK:
4764 case TV_DAEMON_BOOK:
4765 case TV_CRUSADE_BOOK:
4767 case TV_HISSATSU_BOOK:
4770 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4774 /* Rings -- Rings of Speed are good */
4777 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4778 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4782 /* Amulets -- Amulets of the Magi and Resistance are good */
4785 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4786 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4791 /* Assume not good */
4796 * @brief 生成階に応じたベースアイテムの生成を行う。
4797 * Attempt to make an object (normal or good/great)
4798 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4799 * @param mode オプションフラグ
4800 * @return 生成に成功したらTRUEを返す。
4802 * This routine plays nasty games to generate the "special artifacts".\n
4803 * This routine uses "object_level" for the "generation level".\n
4804 * We assume that the given object has been "wiped".\n
4806 bool make_object(object_type *j_ptr, u32b mode)
4812 /* Chance of "special object" */
4813 prob = ((mode & AM_GOOD) ? 10 : 1000);
4815 /* Base level for the object */
4816 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4819 /* Generate a special object, or a normal object */
4820 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4825 if ((mode & AM_GOOD) && !get_obj_num_hook)
4827 /* Activate restriction (if already specified, use that) */
4828 get_obj_num_hook = kind_is_good;
4831 /* Restricted objects - prepare allocation table */
4832 if (get_obj_num_hook) get_obj_num_prep();
4834 /* Pick a random object */
4835 k_idx = get_obj_num(base);
4837 /* Restricted objects */
4838 if (get_obj_num_hook)
4840 /* Clear restriction */
4841 get_obj_num_hook = NULL;
4843 /* Reset allocation table to default */
4847 /* Handle failure */
4848 if (!k_idx) return (FALSE);
4850 /* Prepare the object */
4851 object_prep(j_ptr, k_idx);
4854 /* Apply magic (allow artifacts) */
4855 apply_magic(j_ptr, object_level, mode);
4857 /* Hack -- generate multiple spikes/missiles */
4858 switch (j_ptr->tval)
4866 j_ptr->number = (byte)damroll(6, 7);
4870 obj_level = k_info[j_ptr->k_idx].level;
4871 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4873 /* Notice "okay" out-of-depth objects */
4874 if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
4875 (obj_level > dun_level))
4877 /* Cheat -- peek at items */
4878 if (cheat_peek) object_mention(j_ptr);
4887 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4888 * Attempt to place an object (normal or good/great) at the given location.
4889 * @param y 配置したいフロアのY座標
4890 * @param x 配置したいフロアのX座標
4891 * @param mode オプションフラグ
4892 * @return 生成に成功したらTRUEを返す。
4894 * This routine plays nasty games to generate the "special artifacts".\n
4895 * This routine uses "object_level" for the "generation level".\n
4896 * This routine requires a clean floor grid destination.\n
4898 void place_object(int y, int x, u32b mode)
4903 cave_type *c_ptr = &cave[y][x];
4909 /* Paranoia -- check bounds */
4910 if (!in_bounds(y, x)) return;
4912 /* Require floor space */
4913 if (!cave_drop_bold(y, x)) return;
4915 /* Avoid stacking on other objects */
4916 if (c_ptr->o_idx) return;
4919 /* Get local object */
4922 /* Wipe the object */
4925 /* Make an object (if possible) */
4926 if (!make_object(q_ptr, mode)) return;
4929 /* Make an object */
4937 /* Acquire object */
4938 o_ptr = &o_list[o_idx];
4940 /* Structure Copy */
4941 object_copy(o_ptr, q_ptr);
4948 o_ptr->next_o_idx = c_ptr->o_idx;
4950 /* Place the object */
4951 c_ptr->o_idx = o_idx;
4961 /* Hack -- Preserve artifacts */
4962 if (object_is_fixed_artifact(q_ptr))
4964 a_info[q_ptr->name1].cur_num = 0;
4971 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4972 * Make a treasure object
4973 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4974 * @return 生成に成功したらTRUEを返す。
4976 * The location must be a legal, clean, floor grid.
4978 bool make_gold(object_type *j_ptr)
4985 /* Hack -- Pick a Treasure variety */
4986 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4988 /* Apply "extra" magic */
4989 if (one_in_(GREAT_OBJ))
4991 i += randint1(object_level + 1);
4994 /* Hack -- Creeping Coins only generate "themselves" */
4995 if (coin_type) i = coin_type;
4997 /* Do not create "illegal" Treasure Types */
4998 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
5000 /* Prepare a gold object */
5001 object_prep(j_ptr, OBJ_GOLD_LIST + i);
5003 /* Hack -- Base coin cost */
5004 base = k_info[OBJ_GOLD_LIST+i].cost;
5006 /* Determine how much the treasure is "worth" */
5007 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5015 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
5016 * Places a treasure (Gold or Gems) at given location
5017 * @param y 配置したいフロアのY座標
5018 * @param x 配置したいフロアのX座標
5019 * @return 生成に成功したらTRUEを返す。
5021 * The location must be a legal, clean, floor grid.
5023 void place_gold(int y, int x)
5028 cave_type *c_ptr = &cave[y][x];
5035 /* Paranoia -- check bounds */
5036 if (!in_bounds(y, x)) return;
5038 /* Require floor space */
5039 if (!cave_drop_bold(y, x)) return;
5041 /* Avoid stacking on other objects */
5042 if (c_ptr->o_idx) return;
5045 /* Get local object */
5048 /* Wipe the object */
5051 /* Make some gold */
5052 if (!make_gold(q_ptr)) return;
5055 /* Make an object */
5063 /* Acquire object */
5064 o_ptr = &o_list[o_idx];
5066 /* Copy the object */
5067 object_copy(o_ptr, q_ptr);
5074 o_ptr->next_o_idx = c_ptr->o_idx;
5076 /* Place the object */
5077 c_ptr->o_idx = o_idx;
5089 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5090 * Let an object fall to the ground at or near a location.
5091 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5092 * @param chance ドロップの成功率(%)
5093 * @param y 配置したいフロアのY座標
5094 * @param x 配置したいフロアのX座標
5095 * @return 生成に成功したらTRUEを返す。
5097 * The initial location is assumed to be "in_bounds()".\n
5099 * This function takes a parameter "chance". This is the percentage\n
5100 * chance that the item will "disappear" instead of drop. If the object\n
5101 * has been thrown, then this is the chance of disappearance on contact.\n
5103 * Hack -- this function uses "chance" to determine if it should produce\n
5104 * some form of "description" of the drop event (under the player).\n
5106 * We check several locations to see if we can find a location at which\n
5107 * the object can combine, stack, or be placed. Artifacts will try very\n
5108 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5110 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5121 s16b this_o_idx, next_o_idx = 0;
5125 char o_name[MAX_NLEN];
5131 /* Extract plural */
5132 bool plural = (j_ptr->number != 1);
5135 /* Describe object */
5136 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5139 /* Handle normal "breakage" */
5140 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5144 msg_format("%sは消えた。", o_name);
5146 msg_format("The %s disappear%s.",
5147 o_name, (plural ? "" : "s"));
5152 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5169 /* Scan local grids */
5170 for (dy = -3; dy <= 3; dy++)
5172 /* Scan local grids */
5173 for (dx = -3; dx <= 3; dx++)
5177 /* Calculate actual distance */
5178 d = (dy * dy) + (dx * dx);
5180 /* Ignore distant grids */
5181 if (d > 10) continue;
5187 /* Skip illegal grids */
5188 if (!in_bounds(ty, tx)) continue;
5190 /* Require line of projection */
5191 if (!projectable(y, x, ty, tx)) continue;
5194 c_ptr = &cave[ty][tx];
5196 /* Require floor space */
5197 if (!cave_drop_bold(ty, tx)) continue;
5202 /* Scan objects in that grid */
5203 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5207 /* Acquire object */
5208 o_ptr = &o_list[this_o_idx];
5210 /* Acquire next object */
5211 next_o_idx = o_ptr->next_o_idx;
5213 /* Check for possible combination */
5214 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5220 /* Add new object */
5224 if (k > 99) continue;
5226 /* Calculate score */
5227 s = 1000 - (d + k * 5);
5229 /* Skip bad values */
5230 if (s < bs) continue;
5232 /* New best value */
5235 /* Apply the randomizer to equivalent values */
5236 if ((++bn >= 2) && !one_in_(bn)) continue;
5251 /* Handle lack of space */
5252 if (!flag && !object_is_artifact(j_ptr))
5256 msg_format("%sは消えた。", o_name);
5258 msg_format("The %s disappear%s.",
5259 o_name, (plural ? "" : "s"));
5264 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5272 for (i = 0; !flag && (i < 1000); i++)
5275 ty = rand_spread(by, 1);
5276 tx = rand_spread(bx, 1);
5278 /* Verify location */
5279 if (!in_bounds(ty, tx)) continue;
5281 /* Bounce to that location */
5285 /* Require floor space */
5286 if (!cave_drop_bold(by, bx)) continue;
5295 int candidates = 0, pick;
5297 for (ty = 1; ty < cur_hgt - 1; ty++)
5299 for (tx = 1; tx < cur_wid - 1; tx++)
5301 /* A valid space found */
5302 if (cave_drop_bold(ty, tx)) candidates++;
5306 /* No valid place! */
5311 msg_format("%sは消えた。", o_name);
5313 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5317 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5319 /* Mega-Hack -- preserve artifacts */
5322 /* Hack -- Preserve unknown artifacts */
5323 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5325 /* Mega-Hack -- Preserve the artifact */
5326 a_info[j_ptr->name1].cur_num = 0;
5334 /* Choose a random one */
5335 pick = randint1(candidates);
5337 for (ty = 1; ty < cur_hgt - 1; ty++)
5339 for (tx = 1; tx < cur_wid - 1; tx++)
5341 if (cave_drop_bold(ty, tx))
5345 /* Is this a picked one? */
5359 c_ptr = &cave[by][bx];
5361 /* Scan objects in that grid for combination */
5362 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5366 /* Acquire object */
5367 o_ptr = &o_list[this_o_idx];
5369 /* Acquire next object */
5370 next_o_idx = o_ptr->next_o_idx;
5372 /* Check for combination */
5373 if (object_similar(o_ptr, j_ptr))
5375 /* Combine the items */
5376 object_absorb(o_ptr, j_ptr);
5386 /* Get new object */
5387 if (!done) o_idx = o_pop();
5390 if (!done && !o_idx)
5394 msg_format("%sは消えた。", o_name);
5396 msg_format("The %s disappear%s.",
5397 o_name, (plural ? "" : "s"));
5402 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5404 /* Hack -- Preserve artifacts */
5405 if (object_is_fixed_artifact(j_ptr))
5407 a_info[j_ptr->name1].cur_num = 0;
5417 /* Structure copy */
5418 object_copy(&o_list[o_idx], j_ptr);
5420 /* Access new object */
5421 j_ptr = &o_list[o_idx];
5428 j_ptr->held_m_idx = 0;
5431 j_ptr->next_o_idx = c_ptr->o_idx;
5433 /* Place the object */
5434 c_ptr->o_idx = o_idx;
5449 /* Mega-Hack -- no message if "dropped" by player */
5450 /* Message when an object falls under the player */
5451 if (chance && player_bold(by, bx))
5453 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5465 * Scatter some "great" objects near the player
5466 * @param y1 配置したいフロアのY座標
5467 * @param x1 配置したいフロアのX座標
5468 * @param num 獲得の処理回数
5469 * @param great TRUEならば必ず高級品以上を落とす
5470 * @param special TRUEならば必ず特別品を落とす
5471 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5474 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5477 object_type object_type_body;
5478 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5483 /* Get local object */
5484 i_ptr = &object_type_body;
5486 /* Wipe the object */
5489 /* Make a good (or great) object (if possible) */
5490 if (!make_object(i_ptr, mode)) continue;
5494 object_aware(i_ptr);
5495 object_known(i_ptr);
5498 /* Drop the object */
5499 (void)drop_near(i_ptr, -1, y1, x1);
5504 * Scatter some "amusing" objects near the player
5507 #define AMS_NOTHING 0x00 /* No restriction */
5508 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5509 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5510 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5511 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5521 amuse_type amuse_info[] =
5523 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5524 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5525 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5526 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5527 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5528 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5529 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5530 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5531 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5532 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5533 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5534 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5535 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5542 * @param y1 配置したいフロアのY座標
5543 * @param x1 配置したいフロアのX座標
5544 * @param num 誰得の処理回数
5545 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5548 void amusement(int y1, int x1, int num, bool known)
5551 object_type object_type_body;
5554 for (n = 0; amuse_info[n].tval != 0; n++)
5556 t += amuse_info[n].prob;
5562 int i, k_idx, a_idx = 0;
5563 int r = randint0(t);
5564 bool insta_art, fixed_art;
5568 r -= amuse_info[i].prob;
5572 /* Get local object */
5573 i_ptr = &object_type_body;
5575 /* Wipe the object */
5578 /* Wipe the object */
5579 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5581 /* Paranoia - reroll if nothing */
5582 if (!k_idx) continue;
5584 /* Search an artifact index if need */
5585 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5586 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5588 if (insta_art || fixed_art)
5590 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5592 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5593 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5594 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5595 if (a_info[a_idx].cur_num > 0) continue;
5599 if (a_idx >= max_a_idx) continue;
5602 /* Make an object (if possible) */
5603 object_prep(i_ptr, k_idx);
5604 if (a_idx) i_ptr->name1 = a_idx;
5605 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5607 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5609 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5612 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5613 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5617 object_aware(i_ptr);
5618 object_known(i_ptr);
5621 /* Paranoia - reroll if nothing */
5622 if (!(i_ptr->k_idx)) continue;
5624 /* Drop the object */
5625 (void)drop_near(i_ptr, -1, y1, x1);
5632 #define MAX_NORMAL_TRAPS 18
5634 /* See init_feat_variables() in init2.c */
5635 static s16b normal_traps[MAX_NORMAL_TRAPS];
5638 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5641 void init_normal_traps(void)
5645 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5646 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5647 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5648 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5649 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5650 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5651 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5652 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5653 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5654 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5655 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5656 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5657 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5658 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5659 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5660 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5661 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5662 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5666 * @brief 基本トラップをランダムに選択する /
5668 * @return 選択したトラップのID
5670 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5671 * That is, it does not make sense to have spiked pits at 50 feet.\n
5672 * Actually, it is not this routine, but the "trap instantiation"\n
5673 * code, which should also check for "trap doors" on quest levels.\n
5675 s16b choose_random_trap(void)
5682 /* Hack -- pick a trap */
5683 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5685 /* Accept non-trapdoors */
5686 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5688 /* Hack -- no trap doors on special levels */
5689 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5691 /* Hack -- no trap doors on the deepest level */
5692 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5701 * @brief マスに存在するトラップを秘匿する /
5702 * Disclose an invisible trap
5703 * @param y 秘匿したいマスのY座標
5704 * @param x 秘匿したいマスのX座標
5707 void disclose_grid(int y, int x)
5709 cave_type *c_ptr = &cave[y][x];
5711 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5713 /* No longer hidden */
5714 cave_alter_feat(y, x, FF_SECRET);
5716 else if (c_ptr->mimic)
5718 /* No longer hidden */
5730 * @brief マスをトラップを配置する /
5731 * The location must be a legal, naked, floor grid.
5732 * @param y 配置したいマスのY座標
5733 * @param x 配置したいマスのX座標
5735 * Note that all traps start out as "invisible" and "untyped", and then\n
5736 * when they are "discovered" (by detecting them or setting them off),\n
5737 * the trap is "instantiated" as a visible, "typed", trap.\n
5739 void place_trap(int y, int x)
5741 cave_type *c_ptr = &cave[y][x];
5743 /* Paranoia -- verify location */
5744 if (!in_bounds(y, x)) return;
5746 /* Require empty, clean, floor grid */
5747 if (!cave_clean_bold(y, x)) return;
5749 /* Place an invisible trap */
5750 c_ptr->mimic = c_ptr->feat;
5751 c_ptr->feat = choose_random_trap();
5755 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5756 * Describe the charges on an item in the inventory.
5757 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5760 void inven_item_charges(int item)
5762 object_type *o_ptr = &inventory[item];
5764 /* Require staff/wand */
5765 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5767 /* Require known item */
5768 if (!object_is_known(o_ptr)) return;
5771 if (o_ptr->pval <= 0)
5773 msg_print("もう魔力が残っていない。");
5777 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5780 /* Multiple charges */
5781 if (o_ptr->pval != 1)
5783 /* Print a message */
5784 msg_format("You have %d charges remaining.", o_ptr->pval);
5790 /* Print a message */
5791 msg_format("You have %d charge remaining.", o_ptr->pval);
5798 * @brief アイテムの残り所持数メッセージを表示する /
5799 * Describe an item in the inventory.
5800 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5803 void inven_item_describe(int item)
5805 object_type *o_ptr = &inventory[item];
5806 char o_name[MAX_NLEN];
5808 /* Get a description */
5809 object_desc(o_name, o_ptr, 0);
5811 /* Print a message */
5813 /* "no more" の場合はこちらで表示する */
5814 if (o_ptr->number <= 0)
5816 /*FIRST*//*ここはもう通らないかも */
5817 msg_format("もう%sを持っていない。", o_name);
5821 /* アイテム名を英日切り替え機能対応 */
5822 msg_format("まだ %sを持っている。", o_name);
5825 msg_format("You have %s.", o_name);
5831 * @brief アイテムの残り所持数メッセージを表示する /
5832 * Increase the "number" of an item in the inventory
5833 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5837 void inven_item_increase(int item, int num)
5839 object_type *o_ptr = &inventory[item];
5842 num += o_ptr->number;
5845 if (num > 255) num = 255;
5846 else if (num < 0) num = 0;
5849 num -= o_ptr->number;
5851 /* Change the number and weight */
5854 /* Add the number */
5855 o_ptr->number += num;
5857 /* Add the weight */
5858 p_ptr->total_weight += (num * o_ptr->weight);
5860 /* Recalculate bonuses */
5861 p_ptr->update |= (PU_BONUS);
5863 /* Recalculate mana XXX */
5864 p_ptr->update |= (PU_MANA);
5866 /* Combine the pack */
5867 p_ptr->notice |= (PN_COMBINE);
5870 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5872 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5873 if (!o_ptr->number && p_ptr->ele_attack)
5875 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5877 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5879 /* Clear all temporary elemental brands */
5880 set_ele_attack(0, 0);
5888 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5889 * Erase an inventory slot if it has no more items
5890 * @param item 消去したいプレイヤーのアイテム所持スロット
5893 void inven_item_optimize(int item)
5895 object_type *o_ptr = &inventory[item];
5897 /* Only optimize real items */
5898 if (!o_ptr->k_idx) return;
5900 /* Only optimize empty items */
5901 if (o_ptr->number) return;
5903 /* The item is in the pack */
5904 if (item < INVEN_RARM)
5911 /* Slide everything down */
5912 for (i = item; i < INVEN_PACK; i++)
5914 /* Structure copy */
5915 inventory[i] = inventory[i+1];
5918 /* Erase the "final" slot */
5919 object_wipe(&inventory[i]);
5922 p_ptr->window |= (PW_INVEN);
5925 /* The item is being wielded */
5931 /* Erase the empty slot */
5932 object_wipe(&inventory[item]);
5934 /* Recalculate bonuses */
5935 p_ptr->update |= (PU_BONUS);
5937 /* Recalculate torch */
5938 p_ptr->update |= (PU_TORCH);
5940 /* Recalculate mana XXX */
5941 p_ptr->update |= (PU_MANA);
5944 p_ptr->window |= (PW_EQUIP);
5948 p_ptr->window |= (PW_SPELL);
5952 * @brief 床上の魔道具の残り残量メッセージを表示する /
5953 * Describe the charges on an item on the floor.
5954 * @param item メッセージの対象にしたいアイテム所持スロット
5957 void floor_item_charges(int item)
5959 object_type *o_ptr = &o_list[item];
5961 /* Require staff/wand */
5962 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5964 /* Require known item */
5965 if (!object_is_known(o_ptr)) return;
5968 if (o_ptr->pval <= 0)
5970 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5974 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5977 /* Multiple charges */
5978 if (o_ptr->pval != 1)
5980 /* Print a message */
5981 msg_format("There are %d charges remaining.", o_ptr->pval);
5987 /* Print a message */
5988 msg_format("There is %d charge remaining.", o_ptr->pval);
5995 * @brief 床上のアイテムの残り数メッセージを表示する /
5996 * Describe the charges on an item on the floor.
5997 * @param item メッセージの対象にしたいアイテム所持スロット
6000 void floor_item_describe(int item)
6002 object_type *o_ptr = &o_list[item];
6003 char o_name[MAX_NLEN];
6005 /* Get a description */
6006 object_desc(o_name, o_ptr, 0);
6008 /* Print a message */
6010 /* "no more" の場合はこちらで表示を分ける */
6011 if (o_ptr->number <= 0)
6013 msg_format("床上には、もう%sはない。", o_name);
6017 msg_format("床上には、まだ %sがある。", o_name);
6020 msg_format("You see %s.", o_name);
6027 * @brief 床上のアイテムの数を増やす /
6028 * Increase the "number" of an item on the floor
6029 * @param item 増やしたいアイテムの所持スロット
6030 * @param num 増やしたいアイテムの数
6033 void floor_item_increase(int item, int num)
6035 object_type *o_ptr = &o_list[item];
6038 num += o_ptr->number;
6041 if (num > 255) num = 255;
6042 else if (num < 0) num = 0;
6045 num -= o_ptr->number;
6047 /* Change the number */
6048 o_ptr->number += num;
6053 * @brief 床上の数の無くなったアイテムスロットを消去する /
6054 * Optimize an item on the floor (destroy "empty" items)
6055 * @param item 消去したいアイテムの所持スロット
6058 void floor_item_optimize(int item)
6060 object_type *o_ptr = &o_list[item];
6062 /* Paranoia -- be sure it exists */
6063 if (!o_ptr->k_idx) return;
6065 /* Only optimize empty items */
6066 if (o_ptr->number) return;
6068 /* Delete the object */
6069 delete_object_idx(item);
6074 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6075 * Check if we have space for an item in the pack without overflow
6076 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6077 * @return 溢れずに済むならTRUEを返す
6079 bool inven_carry_okay(object_type *o_ptr)
6084 if (inven_cnt < INVEN_PACK) return (TRUE);
6087 for (j = 0; j < INVEN_PACK; j++)
6089 object_type *j_ptr = &inventory[j];
6091 /* Skip non-objects */
6092 if (!j_ptr->k_idx) continue;
6094 /* Check if the two items can be combined */
6095 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6103 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6104 * Check if we have space for an item in the pack without overflow
6105 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6106 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6107 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6108 * @return o_ptrの方が上位ならばTRUEを返す。
6110 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6114 /* Use empty slots */
6115 if (!j_ptr->k_idx) return TRUE;
6117 /* Hack -- readable books always come first */
6118 if ((o_ptr->tval == REALM1_BOOK) &&
6119 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6120 if ((j_ptr->tval == REALM1_BOOK) &&
6121 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6123 if ((o_ptr->tval == REALM2_BOOK) &&
6124 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6125 if ((j_ptr->tval == REALM2_BOOK) &&
6126 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6128 /* Objects sort by decreasing type */
6129 if (o_ptr->tval > j_ptr->tval) return TRUE;
6130 if (o_ptr->tval < j_ptr->tval) return FALSE;
6132 /* Non-aware (flavored) items always come last */
6133 /* Can happen in the home */
6134 if (!object_is_aware(o_ptr)) return FALSE;
6135 if (!object_is_aware(j_ptr)) return TRUE;
6137 /* Objects sort by increasing sval */
6138 if (o_ptr->sval < j_ptr->sval) return TRUE;
6139 if (o_ptr->sval > j_ptr->sval) return FALSE;
6141 /* Unidentified objects always come last */
6142 /* Objects in the home can be unknown */
6143 if (!object_is_known(o_ptr)) return FALSE;
6144 if (!object_is_known(j_ptr)) return TRUE;
6146 /* Fixed artifacts, random artifacts and ego items */
6147 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6148 else if (o_ptr->art_name) o_type = 2;
6149 else if (object_is_ego(o_ptr)) o_type = 1;
6152 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6153 else if (j_ptr->art_name) j_type = 2;
6154 else if (object_is_ego(j_ptr)) j_type = 1;
6157 if (o_type < j_type) return TRUE;
6158 if (o_type > j_type) return FALSE;
6160 switch (o_ptr->tval)
6166 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6167 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6173 /* Objects sort by increasing hit/damage bonuses */
6174 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6175 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6178 /* Hack: otherwise identical rods sort by
6179 increasing recharge time --dsb */
6181 if (o_ptr->pval < j_ptr->pval) return TRUE;
6182 if (o_ptr->pval > j_ptr->pval) return FALSE;
6186 /* Objects sort by decreasing value */
6187 return o_value > object_value(j_ptr);
6192 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6193 * Add an item to the players inventory, and return the slot used.
6194 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6195 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6197 * If the new item can combine with an existing item in the inventory,\n
6198 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6199 * the item will be placed into the "proper" location in the inventory.\n
6201 * This function can be used to "over-fill" the player's pack, but only\n
6202 * once, and such an action must trigger the "overflow" code immediately.\n
6203 * Note that when the pack is being "over-filled", the new item must be\n
6204 * placed into the "overflow" slot, and the "overflow" must take place\n
6205 * before the pack is reordered, but (optionally) after the pack is\n
6206 * combined. This may be tricky. See "dungeon.c" for info.\n
6208 * Note that this code must remove any location/stack information\n
6209 * from the object once it is placed into the inventory.\n
6211 s16b inven_carry(object_type *o_ptr)
6219 /* Check for combining */
6220 for (j = 0; j < INVEN_PACK; j++)
6222 j_ptr = &inventory[j];
6224 /* Skip non-objects */
6225 if (!j_ptr->k_idx) continue;
6227 /* Hack -- track last item */
6230 /* Check if the two items can be combined */
6231 if (object_similar(j_ptr, o_ptr))
6233 /* Combine the items */
6234 object_absorb(j_ptr, o_ptr);
6236 /* Increase the weight */
6237 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6239 /* Recalculate bonuses */
6240 p_ptr->update |= (PU_BONUS);
6243 p_ptr->window |= (PW_INVEN);
6252 if (inven_cnt > INVEN_PACK) return (-1);
6254 /* Find an empty slot */
6255 for (j = 0; j <= INVEN_PACK; j++)
6257 j_ptr = &inventory[j];
6259 /* Use it if found */
6260 if (!j_ptr->k_idx) break;
6267 /* Reorder the pack */
6270 /* Get the "value" of the item */
6271 s32b o_value = object_value(o_ptr);
6273 /* Scan every occupied slot */
6274 for (j = 0; j < INVEN_PACK; j++)
6276 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6283 for (k = n; k >= i; k--)
6285 /* Hack -- Slide the item */
6286 object_copy(&inventory[k+1], &inventory[k]);
6289 /* Wipe the empty slot */
6290 object_wipe(&inventory[i]);
6295 object_copy(&inventory[i], o_ptr);
6297 /* Access new object */
6298 j_ptr = &inventory[i];
6301 j_ptr->next_o_idx = 0;
6303 /* Forget monster */
6304 j_ptr->held_m_idx = 0;
6306 /* Forget location */
6307 j_ptr->iy = j_ptr->ix = 0;
6309 /* Player touches it, and no longer marked */
6310 j_ptr->marked = OM_TOUCHED;
6312 /* Increase the weight */
6313 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6315 /* Count the items */
6318 /* Recalculate bonuses */
6319 p_ptr->update |= (PU_BONUS);
6321 /* Combine and Reorder pack */
6322 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6325 p_ptr->window |= (PW_INVEN);
6327 /* Return the slot */
6333 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6334 * Take off (some of) a non-cursed equipment item
6335 * @param item オブジェクトを外したい所持テーブルのID
6337 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6339 * Note that only one item at a time can be wielded per slot.\n
6340 * Note that taking off an item when "full" may cause that item\n
6341 * to fall to the ground.\n
6342 * Return the inventory slot into which the item is placed.\n
6344 s16b inven_takeoff(int item, int amt)
6355 char o_name[MAX_NLEN];
6358 /* Get the item to take off */
6359 o_ptr = &inventory[item];
6362 if (amt <= 0) return (-1);
6365 if (amt > o_ptr->number) amt = o_ptr->number;
6367 /* Get local object */
6370 /* Obtain a local object */
6371 object_copy(q_ptr, o_ptr);
6373 /* Modify quantity */
6374 q_ptr->number = amt;
6376 /* Describe the object */
6377 object_desc(o_name, q_ptr, 0);
6379 /* Took off weapon */
6380 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6381 object_is_melee_weapon(o_ptr))
6383 act = _("を装備からはずした", "You were wielding");
6387 else if (item == INVEN_BOW)
6389 act = _("を装備からはずした", "You were holding");
6392 /* Took off light */
6393 else if (item == INVEN_LITE)
6395 act = _("を光源からはずした", "You were holding");
6398 /* Took off something */
6401 act = _("を装備からはずした", "You were wearing");
6404 /* Modify, Optimize */
6405 inven_item_increase(item, -amt);
6406 inven_item_optimize(item);
6408 /* Carry the object */
6409 slot = inven_carry(q_ptr);
6413 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6415 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6425 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6426 * Drop (some of) a non-cursed inventory/equipment item
6427 * @param item 所持テーブルのID
6428 * @param amt 落としたい個数
6431 * The object will be dropped "near" the current location
6433 void inven_drop(int item, int amt)
6440 char o_name[MAX_NLEN];
6443 /* Access original object */
6444 o_ptr = &inventory[item];
6447 if (amt <= 0) return;
6450 if (amt > o_ptr->number) amt = o_ptr->number;
6453 /* Take off equipment */
6454 if (item >= INVEN_RARM)
6456 /* Take off first */
6457 item = inven_takeoff(item, amt);
6459 /* Access original object */
6460 o_ptr = &inventory[item];
6464 /* Get local object */
6467 /* Obtain local object */
6468 object_copy(q_ptr, o_ptr);
6470 /* Distribute charges of wands or rods */
6471 distribute_charges(o_ptr, q_ptr, amt);
6473 /* Modify quantity */
6474 q_ptr->number = amt;
6476 /* Describe local object */
6477 object_desc(o_name, q_ptr, 0);
6480 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6482 /* Drop it near the player */
6483 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6485 /* Modify, Describe, Optimize */
6486 inven_item_increase(item, -amt);
6487 inven_item_describe(item);
6488 inven_item_optimize(item);
6493 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6494 * Combine items in the pack
6497 * Note special handling of the "overflow" slot
6499 void combine_pack(void)
6504 bool flag = FALSE, combined;
6510 /* Combine the pack (backwards) */
6511 for (i = INVEN_PACK; i > 0; i--)
6514 o_ptr = &inventory[i];
6516 /* Skip empty items */
6517 if (!o_ptr->k_idx) continue;
6519 /* Scan the items above that item */
6520 for (j = 0; j < i; j++)
6525 j_ptr = &inventory[j];
6527 /* Skip empty items */
6528 if (!j_ptr->k_idx) continue;
6531 * Get maximum number of the stack if these
6532 * are similar, get zero otherwise.
6534 max_num = object_similar_part(j_ptr, o_ptr);
6536 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6537 if (max_num && j_ptr->number < max_num)
6539 if (o_ptr->number + j_ptr->number <= max_num)
6544 /* Add together the item counts */
6545 object_absorb(j_ptr, o_ptr);
6547 /* One object is gone */
6550 /* Slide everything down */
6551 for (k = i; k < INVEN_PACK; k++)
6553 /* Structure copy */
6554 inventory[k] = inventory[k+1];
6557 /* Erase the "final" slot */
6558 object_wipe(&inventory[k]);
6562 int old_num = o_ptr->number;
6563 int remain = j_ptr->number + o_ptr->number - max_num;
6565 o_ptr->number -= remain;
6567 /* Add together the item counts */
6568 object_absorb(j_ptr, o_ptr);
6570 o_ptr->number = remain;
6572 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6573 if (o_ptr->tval == TV_ROD)
6575 o_ptr->pval = o_ptr->pval * remain / old_num;
6576 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6579 /* Hack -- if wands are stacking, combine the charges. -LM- */
6580 if (o_ptr->tval == TV_WAND)
6582 o_ptr->pval = o_ptr->pval * remain / old_num;
6587 p_ptr->window |= (PW_INVEN);
6601 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6605 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6606 * Reorder items in the pack
6609 * Note special handling of the "overflow" slot
6611 void reorder_pack(void)
6621 /* Re-order the pack (forwards) */
6622 for (i = 0; i < INVEN_PACK; i++)
6624 /* Mega-Hack -- allow "proper" over-flow */
6625 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6628 o_ptr = &inventory[i];
6630 /* Skip empty slots */
6631 if (!o_ptr->k_idx) continue;
6633 /* Get the "value" of the item */
6634 o_value = object_value(o_ptr);
6636 /* Scan every occupied slot */
6637 for (j = 0; j < INVEN_PACK; j++)
6639 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6642 /* Never move down */
6643 if (j >= i) continue;
6648 /* Get local object */
6651 /* Save a copy of the moving item */
6652 object_copy(q_ptr, &inventory[i]);
6654 /* Slide the objects */
6655 for (k = i; k > j; k--)
6657 /* Slide the item */
6658 object_copy(&inventory[k], &inventory[k-1]);
6661 /* Insert the moving item */
6662 object_copy(&inventory[j], q_ptr);
6665 p_ptr->window |= (PW_INVEN);
6669 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6673 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6674 * Hack -- display an object kind in the current window
6675 * @param k_idx ベースアイテムの参照ID
6678 * Include list of usable spells for readible books
6680 void display_koff(int k_idx)
6689 char o_name[MAX_NLEN];
6692 /* Erase the window */
6693 for (y = 0; y < Term->hgt; y++)
6695 /* Erase the line */
6696 Term_erase(0, y, 255);
6702 /* Get local object */
6705 /* Prepare the object */
6706 object_prep(q_ptr, k_idx);
6709 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6711 /* Mention the object name */
6712 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6714 /* Access the item's sval */
6716 use_realm = tval2realm(q_ptr->tval);
6718 /* Warriors are illiterate */
6719 if (p_ptr->realm1 || p_ptr->realm2)
6721 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6725 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6726 if (!is_magic(use_realm)) return;
6727 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6730 /* Display spells in readible books */
6736 /* Extract spells */
6737 for (spell = 0; spell < 32; spell++)
6739 /* Check for this spell */
6740 if (fake_spell_flags[sval] & (1L << spell))
6742 /* Collect this spell */
6743 spells[num++] = spell;
6748 print_spells(0, spells, num, 2, 0, use_realm);
6753 * @brief 警告を放つアイテムを選択する /
6754 * Choose one of items that have warning flag
6755 * Calculate spell damages
6758 object_type *choose_warning_item(void)
6761 int choices[INVEN_TOTAL - INVEN_RARM];
6764 /* Paranoia -- Player has no warning ability */
6765 if (!p_ptr->warning) return NULL;
6767 /* Search Inventory */
6768 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6770 u32b flgs[TR_FLAG_SIZE];
6771 object_type *o_ptr = &inventory[i];
6773 object_flags(o_ptr, flgs);
6774 if (have_flag(flgs, TR_WARNING))
6776 choices[number] = i;
6781 /* Choice one of them */
6782 return number ? &inventory[choices[randint0(number)]] : NULL;
6786 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6787 * Calculate spell damages
6788 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6789 * @param typ 効果属性のID
6791 * @param max 算出した最大ダメージを返すポインタ
6794 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int *max)
6796 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6797 int rlev = r_ptr->level;
6798 bool ignore_wraith_form = FALSE;
6800 /* Vulnerability, resistance and immunity */
6804 if (p_ptr->immune_elec)
6807 ignore_wraith_form = TRUE;
6811 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6812 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6813 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6814 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6815 if (IS_OPPOSE_ELEC())
6816 dam = (dam + 2) / 3;
6821 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6822 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6826 if (p_ptr->immune_acid)
6829 ignore_wraith_form = TRUE;
6833 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6834 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6835 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6836 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6842 if (p_ptr->immune_cold)
6845 ignore_wraith_form = TRUE;
6849 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6850 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6851 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6852 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6857 if (p_ptr->immune_fire)
6860 ignore_wraith_form = TRUE;
6864 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6865 if (prace_is_(RACE_ENT)) dam += dam / 3;
6866 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6867 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6868 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6873 ignore_wraith_form = TRUE;
6877 if (!p_ptr->blind &&
6878 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6879 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6882 ignore_wraith_form = TRUE;
6887 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6888 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6889 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6892 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6893 * "dam *= 2;" for later "dam /= 2"
6895 if (p_ptr->wraith_form) dam *= 2;
6899 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6902 ignore_wraith_form = TRUE;
6904 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6908 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6912 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6916 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6920 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6924 if (prace_is_(RACE_SPECTRE))
6927 ignore_wraith_form = TRUE;
6929 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6933 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6937 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6941 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6945 if (p_ptr->levitation) dam = (dam * 2) / 3;
6949 if (p_ptr->resist_shard) dam /= 2;
6953 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6954 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6958 if (p_ptr->mimic_form)
6960 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6963 ignore_wraith_form = TRUE;
6968 switch (p_ptr->prace)
6977 ignore_wraith_form = TRUE;
6984 if (p_ptr->align > 10) dam /= 2;
6985 else if (p_ptr->align < -10) dam *= 2;
6989 if (p_ptr->align > 10) dam *= 2;
6993 case GF_BRAIN_SMASH:
6994 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6997 ignore_wraith_form = TRUE;
7005 if (100 + rlev / 2 <= p_ptr->skill_sav)
7008 ignore_wraith_form = TRUE;
7013 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
7016 ignore_wraith_form = TRUE;
7021 if (p_ptr->wraith_form && !ignore_wraith_form)
7027 if (dam > *max) *max = dam;
7031 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
7032 * Calculate spell damages
7033 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
7034 * @param typ 効果属性のID
7035 * @param m_idx 魔法を行使するモンスターのID
7036 * @param max 算出した最大ダメージを返すポインタ
7039 void spell_damcalc_by_spellnum(int spell_num, int typ, int m_idx, int *max)
7041 monster_type *m_ptr = &m_list[m_idx];
7042 int dam = monspell_damage((spell_num), m_idx, DAM_MAX);
7043 spell_damcalc(m_ptr, typ, dam, max);
7047 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
7048 * Calculate blow damages
7049 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
7050 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
7051 * @return 算出された最大ダメージを返す。
7053 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7055 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7057 bool check_wraith_form = TRUE;
7059 if (blow_ptr->method != RBM_EXPLODE)
7061 int ac = p_ptr->ac + p_ptr->to_a;
7063 switch (blow_ptr->effect)
7067 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7068 dam = MAX(dam, tmp_dam * 2);
7074 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7078 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7080 check_wraith_form = FALSE;
7084 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7086 check_wraith_form = FALSE;
7090 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7092 check_wraith_form = FALSE;
7096 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7098 check_wraith_form = FALSE;
7103 check_wraith_form = FALSE;
7107 if (check_wraith_form && p_ptr->wraith_form)
7115 dam = (dam + 1) / 2;
7116 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7124 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7125 * Examine the grid (xx,yy) and warn the player if there are any danger
7126 * @param xx 危険性を調査するマスのX座標
7127 * @param yy 危険性を調査するマスのY座標
7128 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7130 bool process_warning(int xx, int yy)
7134 char o_name[MAX_NLEN];
7136 #define WARNING_AWARE_RANGE 12
7138 static int old_damage = 0;
7140 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7142 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7145 monster_type *m_ptr;
7146 monster_race *r_ptr;
7148 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7150 c_ptr = &cave[my][mx];
7152 if (!c_ptr->m_idx) continue;
7154 m_ptr = &m_list[c_ptr->m_idx];
7156 if (MON_CSLEEP(m_ptr)) continue;
7157 if (!is_hostile(m_ptr)) continue;
7159 r_ptr = &r_info[m_ptr->r_idx];
7161 /* Monster spells (only powerful ones)*/
7162 if (projectable(my, mx, yy, xx))
7164 u32b f4 = r_ptr->flags4;
7165 u32b f5 = r_ptr->flags5;
7166 u32b f6 = r_ptr->flags6;
7168 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7170 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7171 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7172 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7173 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7174 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7175 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7177 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7178 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7179 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7180 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7181 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7182 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7183 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7184 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7185 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7186 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7187 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7188 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7189 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7190 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7191 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7192 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7193 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7194 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7195 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7196 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7197 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7198 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7199 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7202 /* Monster melee attacks */
7203 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7205 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7209 for (m = 0; m < 4; m++)
7211 /* Skip non-attacks */
7212 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7214 /* Extract the attack info */
7215 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7216 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7218 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7222 /* Contribution from this monster */
7223 dam_max += dam_max0;
7227 /* Prevent excessive warning */
7228 if (dam_max > old_damage)
7230 old_damage = dam_max * 3 / 2;
7232 if (dam_max > p_ptr->chp / 2)
7234 object_type *o_ptr = choose_warning_item();
7237 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7239 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7240 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7243 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7246 else old_damage = old_damage / 2;
7248 c_ptr = &cave[yy][xx];
7249 if (((!easy_disarm && is_trap(c_ptr->feat))
7250 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7252 object_type *o_ptr = choose_warning_item();
7255 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7257 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7258 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7260 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7267 * @brief エッセンスの付加可能な武器や矢弾かを返す
7268 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7269 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7271 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7273 switch (o_ptr->tval)
7286 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7295 * エッセンス情報の構造体 / A structure for smithing
7298 int add; /* TR flag number or special essence id */
7299 cptr add_name; /* Name of this ability */
7300 int type; /* Menu number */
7301 int essence; /* Index for carrying essences */
7302 int value; /* Needed value to add this ability */
7307 * エッセンス情報テーブル Smithing type data for Weapon smith
7310 static essence_type essence_info[] =
7312 {TR_STR, "腕力", 4, TR_STR, 20},
7313 {TR_INT, "知能", 4, TR_INT, 20},
7314 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7315 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7316 {TR_CON, "耐久力", 4, TR_CON, 20},
7317 {TR_CHR, "魅力", 4, TR_CHR, 20},
7318 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7319 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7320 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7321 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7322 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7323 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7324 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7325 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7326 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7327 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7328 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7329 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7330 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7331 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7332 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7333 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7334 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7335 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7336 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7337 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7338 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7339 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7340 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7341 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7342 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7343 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7344 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7345 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7346 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7347 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7348 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7349 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7350 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7351 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7352 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7353 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7354 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7355 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7356 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7357 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7358 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7359 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7360 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7361 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7362 {TR_SH_FIRE, "", 0, -2, 0},
7363 {TR_SH_ELEC, "", 0, -2, 0},
7364 {TR_SH_COLD, "", 0, -2, 0},
7365 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7366 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7367 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7368 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7369 {TR_LITE_2, "", 0, -2, 0},
7370 {TR_LITE_3, "", 0, -2, 0},
7371 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7372 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7373 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7374 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7375 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7377 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7378 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7379 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7380 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7381 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7382 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7383 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7384 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7385 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7386 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7387 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7388 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7389 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7390 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7391 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7392 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7393 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7394 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7396 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7397 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7398 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7399 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7400 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7401 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7402 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7403 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7405 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7406 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7407 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7408 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7409 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7410 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7411 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7412 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7413 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7414 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7415 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7416 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7418 {-1, NULL, 0, -1, 0}
7421 static essence_type essence_info[] =
7423 {TR_STR, "strength", 4, TR_STR, 20},
7424 {TR_INT, "intelligence", 4, TR_INT, 20},
7425 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7426 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7427 {TR_CON, "constitution", 4, TR_CON, 20},
7428 {TR_CHR, "charisma", 4, TR_CHR, 20},
7429 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7430 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7431 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7432 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7433 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7434 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7435 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7436 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7437 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7438 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7439 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7440 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7441 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7442 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7443 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7444 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7445 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7446 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7447 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7448 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7449 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7450 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7451 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7452 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7453 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7454 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7455 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7456 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7457 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7458 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7459 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7460 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7461 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7462 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7463 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7464 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7465 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7466 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7467 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7468 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7469 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7470 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7471 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7472 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7473 {TR_SH_FIRE, "", 0, -2, 0},
7474 {TR_SH_ELEC, "", 0, -2, 0},
7475 {TR_SH_COLD, "", 0, -2, 0},
7476 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7477 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7478 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7479 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7480 {TR_LITE_2, "", 0, -2, 0},
7481 {TR_LITE_3, "", 0, -2, 0},
7482 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7483 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7484 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7485 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7486 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7488 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7489 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7490 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7491 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7492 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7493 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7494 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7495 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7496 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7497 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7498 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7499 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7500 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7501 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7502 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7503 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7504 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7505 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7507 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7508 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7509 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7510 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7511 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7512 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7513 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7514 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7516 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7517 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7518 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7519 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7520 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7521 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7522 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7523 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7524 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7525 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7526 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7527 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7529 {-1, NULL, 0, -1, 0}
7535 * エッセンス名テーブル / Essense names for Weapon smith
7538 cptr essence_name[] =
7641 cptr essence_name[] =
7744 * @brief 所持しているエッセンス一覧を表示する
7747 static void display_essence(void)
7752 for (i = 1; i < 22; i++)
7756 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7757 "Essence Num Essence Num Essence Num "), 1, 8);
7758 for (i = 0; essence_name[i]; i++)
7760 if (!essence_name[i][0]) continue;
7761 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7764 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7774 static void drain_essence(void)
7776 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7779 bool observe = FALSE;
7780 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7781 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7784 byte iy, ix, marked, number;
7785 s16b next_o_idx, weight;
7787 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7790 item_tester_hook = object_is_weapon_armour_ammo;
7791 item_tester_no_ryoute = TRUE;
7794 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7795 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7797 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7799 /* Get the item (in the pack) */
7802 o_ptr = &inventory[item];
7805 /* Get the item (on the floor) */
7808 o_ptr = &o_list[0 - item];
7811 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7813 char o_name[MAX_NLEN];
7814 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7815 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7818 p_ptr->energy_use = 100;
7820 object_flags(o_ptr, old_flgs);
7821 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7822 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7823 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7824 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7825 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7826 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7827 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7828 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7829 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7831 old_to_a = o_ptr->to_a;
7833 old_to_h = o_ptr->to_h;
7834 old_to_d = o_ptr->to_d;
7837 old_pval = o_ptr->pval;
7838 old_name2 = o_ptr->name2;
7839 old_timeout = o_ptr->timeout;
7840 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7841 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7842 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7843 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7844 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7845 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7846 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7847 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7848 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7849 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7850 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7851 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7852 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7853 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7854 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7855 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7856 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7857 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7858 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7862 next_o_idx = o_ptr->next_o_idx;
7863 marked = o_ptr->marked;
7864 weight = o_ptr->weight;
7865 number = o_ptr->number;
7867 object_prep(o_ptr, o_ptr->k_idx);
7871 o_ptr->next_o_idx=next_o_idx;
7872 o_ptr->marked=marked;
7873 o_ptr->number = number;
7874 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7875 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7876 o_ptr->ident |= (IDENT_MENTAL);
7877 object_aware(o_ptr);
7878 object_known(o_ptr);
7880 object_flags(o_ptr, new_flgs);
7882 for (i = 0; essence_info[i].add_name; i++)
7884 essence_type *es_ptr = &essence_info[i];
7887 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7888 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7890 if (es_ptr->add < TR_FLAG_MAX &&
7891 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7892 have_flag(old_flgs, es_ptr->add))
7896 drain_value[es_ptr->essence] += 10 * pval;
7898 else if (es_ptr->essence != -2)
7900 drain_value[es_ptr->essence] += 10;
7902 else if (es_ptr->add == TR_SH_FIRE)
7904 drain_value[TR_BRAND_FIRE] += 10;
7905 drain_value[TR_RES_FIRE] += 10;
7907 else if (es_ptr->add == TR_SH_ELEC)
7909 drain_value[TR_BRAND_ELEC] += 10;
7910 drain_value[TR_RES_ELEC] += 10;
7912 else if (es_ptr->add == TR_SH_COLD)
7914 drain_value[TR_BRAND_COLD] += 10;
7915 drain_value[TR_RES_COLD] += 10;
7917 else if (es_ptr->add == TR_LITE_2)
7919 drain_value[TR_LITE_1] += 20;
7921 else if (es_ptr->add == TR_LITE_3)
7923 drain_value[TR_LITE_1] += 30;
7928 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7930 drain_value[TR_INT] += 5;
7931 drain_value[TR_WIS] += 5;
7933 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7935 drain_value[TR_BRAND_POIS] += 5;
7936 drain_value[TR_BRAND_ACID] += 5;
7937 drain_value[TR_BRAND_ELEC] += 5;
7938 drain_value[TR_BRAND_FIRE] += 5;
7939 drain_value[TR_BRAND_COLD] += 5;
7941 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7943 drain_value[TR_INT] += 10;
7945 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7947 drain_value[TR_STR] += 10;
7949 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7951 drain_value[TR_DEX] += 10;
7953 if (old_name2 == EGO_2WEAPON)
7955 drain_value[TR_DEX] += 20;
7957 if (object_is_weapon_ammo(o_ptr))
7959 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7961 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7963 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7964 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7965 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7966 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7968 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7970 drain_value[i] *= number;
7971 drain_value[i] = drain_value[i] * dec / 4;
7972 drain_value[i] = MAX(drain_value[i], 0);
7973 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7981 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7985 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7987 for (i = 0; essence_name[i]; i++)
7989 if (!essence_name[i][0]) continue;
7990 if (!drain_value[i]) continue;
7992 p_ptr->magic_num1[i] += drain_value[i];
7993 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7995 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7999 /* Apply autodestroy/inscription to the drained item */
8000 autopick_alter_item(item, TRUE);
8002 /* Combine the pack */
8003 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8006 p_ptr->window |= (PW_INVEN);
8010 * @brief 付加するエッセンスの大別を選択する
8011 * @return 選んだエッセンスの大別ID
8013 static int choose_essence(void)
8017 int menu_line = (use_menu ? 1 : 0);
8020 cptr menu_name[] = {
8030 cptr menu_name[] = {
8040 const int mode_max = 7;
8043 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
8046 #endif /* ALLOW_REPEAT */
8055 for (i = 0; i < mode_max; i++)
8057 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8058 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8060 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8061 prt("Choose from menu.", 0, 0);
8080 menu_line += mode_max - 1;
8089 if (menu_line > mode_max) menu_line -= mode_max;
8100 for (i = 0; i < mode_max; i++)
8101 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8103 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8109 if (isupper(choice)) choice = tolower(choice);
8111 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8112 mode = (int)choice - 'a' + 1;
8119 #endif /* ALLOW_REPEAT */
8124 * @brief エッセンスを実際に付加する
8125 * @param mode エッセンスの大別ID
8128 static void add_essence(int mode)
8130 int item, max_num = 0;
8139 char o_name[MAX_NLEN];
8141 essence_type *es_ptr;
8143 int menu_line = (use_menu ? 1 : 0);
8145 for (i = 0; essence_info[i].add_name; i++)
8147 es_ptr = &essence_info[i];
8149 if (es_ptr->type != mode) continue;
8154 if (!repeat_pull(&i) || i<0 || i>=max_num)
8156 #endif /* ALLOW_REPEAT */
8159 /* Nothing chosen yet */
8165 /* Build a prompt */
8166 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8167 if (use_menu) screen_save();
8169 /* Get a spell from the user */
8171 choice = (always_show_list || use_menu) ? ESCAPE:1;
8175 if( choice==ESCAPE ) choice = ' ';
8176 else if( !get_com(out_val, &choice, FALSE) )break;
8178 if (use_menu && choice != ' ')
8192 menu_line += (max_num-1);
8215 menu_line = max_num;
8229 if (menu_line > max_num) menu_line -= max_num;
8231 /* Request redraw */
8232 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8235 if (!redraw || use_menu)
8239 char dummy[80], dummy2[80];
8247 /* Save the screen */
8248 if (!use_menu) screen_save();
8250 for (y = 1; y < 24; y++)
8253 /* Print header(s) */
8255 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8258 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8261 for (ctr = 0; ctr < max_num; ctr++)
8263 es_ptr = &essence_info[num[ctr]];
8267 if (ctr == (menu_line-1))
8268 strcpy(dummy, _("》 ", "> "));
8269 else strcpy(dummy, " ");
8272 /* letter/number for power selection */
8275 sprintf(dummy, "%c) ",I2A(ctr));
8278 strcat(dummy, es_ptr->add_name);
8283 if (es_ptr->essence != -1)
8285 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8286 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8292 case ESSENCE_SH_FIRE:
8293 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8294 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8295 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8297 case ESSENCE_SH_ELEC:
8298 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8299 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8300 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8302 case ESSENCE_SH_COLD:
8303 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8304 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8305 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8307 case ESSENCE_RESISTANCE:
8308 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8309 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8310 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8311 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8312 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8314 case ESSENCE_SUSTAIN:
8315 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8316 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8317 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8318 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8319 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8324 if (!able[ctr]) col = TERM_RED;
8326 if (es_ptr->essence != -1)
8328 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8332 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8335 c_prt(col, dummy2, ctr+2, x);
8345 /* Restore the screen */
8356 ask = (isupper(choice));
8359 if (ask) choice = tolower(choice);
8361 /* Extract request */
8362 i = (islower(choice) ? A2I(choice) : -1);
8365 /* Totally Illegal */
8366 if ((i < 0) || (i >= max_num) || !able[i])
8378 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8380 /* Belay that order */
8381 if (!get_check(tmp_val)) continue;
8388 /* Restore the screen */
8389 if (redraw) screen_load();
8396 #endif /* ALLOW_REPEAT */
8398 es_ptr = &essence_info[num[i]];
8400 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8401 item_tester_tval = TV_GLOVES;
8402 else if (mode == 1 || mode == 5)
8403 item_tester_hook = item_tester_hook_melee_ammo;
8404 else if (es_ptr->add == ESSENCE_ATTACK)
8405 item_tester_hook = object_allow_enchant_weapon;
8406 else if (es_ptr->add == ESSENCE_AC)
8407 item_tester_hook = object_is_armour;
8409 item_tester_hook = object_is_weapon_armour_ammo;
8410 item_tester_no_ryoute = TRUE;
8413 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8414 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8416 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8418 /* Get the item (in the pack) */
8421 o_ptr = &inventory[item];
8424 /* Get the item (on the floor) */
8427 o_ptr = &o_list[0 - item];
8430 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8432 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8436 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8438 use_essence = es_ptr->value;
8439 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8440 if (o_ptr->number > 1)
8442 use_essence *= o_ptr->number;
8443 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8446 if (es_ptr->essence != -1)
8448 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8450 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8453 if (is_pval_flag(es_ptr->add))
8455 if (o_ptr->pval < 0)
8457 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8460 else if (es_ptr->add == TR_BLOWS)
8462 if (o_ptr->pval > 1)
8464 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8468 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8470 else if (o_ptr->pval > 0)
8472 use_essence *= o_ptr->pval;
8473 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8480 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8482 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8483 strcpy(tmp_val, "1");
8485 if (!get_string(tmp, tmp_val, 1)) return;
8486 pval = atoi(tmp_val);
8487 if (pval > limit) pval = limit;
8488 else if (pval < 1) pval = 1;
8489 o_ptr->pval += pval;
8490 use_essence *= pval;
8491 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8494 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8496 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8500 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8504 int get_to_h, get_to_d;
8506 strcpy(tmp_val, "1");
8507 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8508 val = atoi(tmp_val);
8509 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8510 else if (val < 1) val = 1;
8512 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8513 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8515 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8518 get_to_h = ((val+1)/2+randint0(val/2+1));
8519 get_to_d = ((val+1)/2+randint0(val/2+1));
8520 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8521 o_ptr->to_h += get_to_h;
8522 o_ptr->to_d += get_to_d;
8524 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8525 if (es_ptr->add == ESSENCE_ATTACK)
8527 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8529 msg_print(_("改良に失敗した。", "You failed to enchant."));
8530 p_ptr->energy_use = 100;
8535 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8536 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8539 else if (es_ptr->add == ESSENCE_AC)
8541 if (o_ptr->to_a >= p_ptr->lev/5+5)
8543 msg_print(_("改良に失敗した。", "You failed to enchant."));
8544 p_ptr->energy_use = 100;
8549 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8554 o_ptr->xtra3 = es_ptr->add + 1;
8559 bool success = TRUE;
8563 case ESSENCE_SH_FIRE:
8564 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8569 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8570 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8572 case ESSENCE_SH_ELEC:
8573 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8578 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8579 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8581 case ESSENCE_SH_COLD:
8582 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8587 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8588 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8590 case ESSENCE_RESISTANCE:
8591 case ESSENCE_SUSTAIN:
8592 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))
8597 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8598 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8599 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8600 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8605 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8608 if (es_ptr->add == ESSENCE_SUSTAIN)
8610 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8611 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8612 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8613 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8617 o_ptr->xtra3 = es_ptr->add + 1;
8621 p_ptr->energy_use = 100;
8624 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8626 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8629 /* Combine the pack */
8630 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8633 p_ptr->window |= (PW_INVEN);
8640 static void erase_essence(void)
8645 char o_name[MAX_NLEN];
8646 u32b flgs[TR_FLAG_SIZE];
8648 item_tester_hook = object_is_smith;
8651 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8652 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8654 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8656 /* Get the item (in the pack) */
8659 o_ptr = &inventory[item];
8662 /* Get the item (on the floor) */
8665 o_ptr = &o_list[0 - item];
8668 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8669 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8671 p_ptr->energy_use = 100;
8673 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8675 o_ptr->to_h -= (o_ptr->xtra4>>8);
8676 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8678 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8679 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8682 object_flags(o_ptr, flgs);
8683 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8684 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8686 /* Combine the pack */
8687 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8690 p_ptr->window |= (PW_INVEN);
8694 * @brief 鍛冶コマンドのメインルーチン
8695 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8698 void do_cmd_kaji(bool only_browse)
8703 int menu_line = (use_menu ? 1 : 0);
8707 if (p_ptr->confused)
8709 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8714 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8719 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8725 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8727 #endif /* ALLOW_REPEAT */
8729 if (only_browse) screen_save();
8731 if (!only_browse) screen_save();
8737 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8738 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8739 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8740 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8741 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8742 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8744 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8745 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8746 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8747 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8748 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8749 prt(format("Choose command from menu."), 0, 0);
8776 if (menu_line > 5) menu_line -= 5;
8785 prt(" a) エッセンス一覧", 2, 14);
8786 prt(" b) エッセンス抽出", 3, 14);
8787 prt(" c) エッセンス消去", 4, 14);
8788 prt(" d) エッセンス付加", 5, 14);
8789 prt(" e) 武器/防具強化", 6, 14);
8790 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8792 prt(" a) List essences", 2, 14);
8793 prt(" b) Extract essence", 3, 14);
8794 prt(" c) Remove essence", 4, 14);
8795 prt(" d) Add essence", 5, 14);
8796 prt(" e) Enchant weapon/armor", 6, 14);
8797 if (!get_com("Command :", &choice, TRUE))
8834 /* Clear lines, position cursor (really should use strlen here) */
8835 Term_erase(14, 21, 255);
8836 Term_erase(14, 20, 255);
8837 Term_erase(14, 19, 255);
8838 Term_erase(14, 18, 255);
8839 Term_erase(14, 17, 255);
8840 Term_erase(14, 16, 255);
8842 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8843 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8845 prt(&temp[j], line, 15);
8850 if (!only_browse) screen_load();
8851 } while (only_browse);
8855 #endif /* ALLOW_REPEAT */
8859 case 1: display_essence();break;
8860 case 2: drain_essence();break;
8861 case 3: erase_essence();break;
8863 mode = choose_essence();
8868 case 5: add_essence(10);break;
8874 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8875 * Torches have special abilities when they are flaming.
8876 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8877 * @param flgs 特別に追加するフラグを返す参照ポインタ
8880 void torch_flags(object_type *o_ptr, u32b *flgs)
8882 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8884 if (o_ptr->xtra4 > 0)
8886 add_flag(flgs, TR_BRAND_FIRE);
8887 add_flag(flgs, TR_KILL_UNDEAD);
8888 add_flag(flgs, TR_THROW);
8894 * @brief 投擲時たいまつにダイスを与える。
8895 * Torches have special abilities when they are flaming.
8896 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8897 * @param dd 特別なダイス数を返す参照ポインタ
8898 * @param ds 特別なダイス面数を返す参照ポインタ
8901 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8903 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8905 if (o_ptr->xtra4 > 0)
8914 * @brief 投擲時命中したたいまつの寿命を縮める。
8915 * Torches have special abilities when they are flaming.
8916 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8919 void torch_lost_fuel(object_type *o_ptr)
8921 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8923 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8924 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;