3 * @brief オブジェクトの実装 / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 #include "object-hook.h"
17 static void one_sustain(object_type *o_ptr);
20 static cptr const kaji_tips[5] =
23 "現在持っているエッセンスの一覧を表示する。",
24 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
25 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
26 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
27 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
29 "Display essences you have.",
30 "Extract essences from an item. The item become non magical.",
31 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
32 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
33 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
38 * @brief 対象のオブジェクトにランダムな能力維持を一つ付加する。/ Choose one random sustain
40 * @param o_ptr 対象のオブジェクト構造体ポインタ
43 static void one_sustain(object_type *o_ptr)
47 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
48 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
49 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
50 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
51 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
52 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
57 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
58 * @param o_idx 削除対象のオブジェクト構造体ポインタ
61 void excise_object_idx(OBJECT_IDX o_idx)
65 s16b this_o_idx, next_o_idx = 0;
71 j_ptr = &o_list[o_idx];
74 if (j_ptr->held_m_idx)
79 m_ptr = &m_list[j_ptr->held_m_idx];
81 /* Scan all objects in the grid */
82 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
87 o_ptr = &o_list[this_o_idx];
89 /* Acquire next object */
90 next_o_idx = o_ptr->next_o_idx;
93 if (this_o_idx == o_idx)
98 /* Remove from list */
99 m_ptr->hold_o_idx = next_o_idx;
107 /* Previous object */
108 k_ptr = &o_list[prev_o_idx];
110 /* Remove from list */
111 k_ptr->next_o_idx = next_o_idx;
114 /* Forget next pointer */
115 o_ptr->next_o_idx = 0;
121 /* Save prev_o_idx */
122 prev_o_idx = this_o_idx;
131 POSITION y = j_ptr->iy;
132 POSITION x = j_ptr->ix;
137 /* Scan all objects in the grid */
138 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
143 o_ptr = &o_list[this_o_idx];
145 /* Acquire next object */
146 next_o_idx = o_ptr->next_o_idx;
149 if (this_o_idx == o_idx)
154 /* Remove from list */
155 c_ptr->o_idx = next_o_idx;
163 /* Previous object */
164 k_ptr = &o_list[prev_o_idx];
166 /* Remove from list */
167 k_ptr->next_o_idx = next_o_idx;
170 /* Forget next pointer */
171 o_ptr->next_o_idx = 0;
177 /* Save prev_o_idx */
178 prev_o_idx = this_o_idx;
184 * @brief オブジェクトを削除する /
185 * Delete a dungeon object
186 * @param o_idx 削除対象のオブジェクト構造体ポインタ
189 * Handle "stacks" of objects correctly.
191 void delete_object_idx(OBJECT_IDX o_idx)
196 excise_object_idx(o_idx);
199 j_ptr = &o_list[o_idx];
202 if (!(j_ptr->held_m_idx))
214 /* Wipe the object */
223 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
224 * Delete a dungeon object
225 * @param y 削除したフロアマスのY座標
226 * @param x 削除したフロアマスのX座標
229 void delete_object(POSITION y, POSITION x)
232 OBJECT_IDX this_o_idx, next_o_idx = 0;
234 /* Refuse "illegal" locations */
235 if (!in_bounds(y, x)) return;
240 /* Scan all objects in the grid */
241 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
246 o_ptr = &o_list[this_o_idx];
248 /* Acquire next object */
249 next_o_idx = o_ptr->next_o_idx;
251 /* Wipe the object */
258 /* Objects are gone */
267 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
268 * Move an object from index i1 to index i2 in the object list
269 * @param i1 整理したい配列の始点
270 * @param i2 整理したい配列の終点
273 static void compact_objects_aux(IDX i1, IDX i2)
280 if (i1 == i2) return;
284 for (i = 1; i < o_max; i++)
289 /* Skip "dead" objects */
290 if (!o_ptr->k_idx) continue;
292 /* Repair "next" pointers */
293 if (o_ptr->next_o_idx == i1)
296 o_ptr->next_o_idx = i2;
306 if (o_ptr->held_m_idx)
310 /* Acquire monster */
311 m_ptr = &m_list[o_ptr->held_m_idx];
314 if (m_ptr->hold_o_idx == i1)
317 m_ptr->hold_o_idx = i2;
326 /* Acquire location */
334 if (c_ptr->o_idx == i1)
343 o_list[i2] = o_list[i1];
351 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
352 * Compact and Reorder the object list.
353 * @param size 最低でも減らしたいオブジェクト数の水準
357 * This function can be very dangerous, use with caution!\n
359 * When actually "compacting" objects, we base the saving throw on a\n
360 * combination of object level, distance from player, and current\n
363 * After "compacting" (if needed), we "reorder" the objects into a more\n
364 * compact order, and we reset the allocation info, and the "live" array.\n
366 void compact_objects(int size)
370 int cur_lev, cur_dis, chance;
378 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
381 p_ptr->redraw |= (PR_MAP);
384 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
388 /* Compact at least 'size' objects */
389 for (num = 0, cnt = 1; num < size; cnt++)
391 /* Get more vicious each iteration */
394 /* Get closer each iteration */
395 cur_dis = 5 * (20 - cnt);
397 /* Examine the objects */
398 for (i = 1; i < o_max; i++)
402 /* Skip dead objects */
403 if (!o_ptr->k_idx) continue;
405 /* Hack -- High level objects start out "immune" */
406 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
409 if (o_ptr->held_m_idx)
413 /* Acquire monster */
414 m_ptr = &m_list[o_ptr->held_m_idx];
416 /* Get the location */
420 /* Monsters protect their objects */
421 if (randint0(100) < 90) continue;
427 /* Get the location */
432 /* Nearby objects start out "immune" */
433 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
438 /* Hack -- only compact artifacts in emergencies */
439 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
440 (cnt < 1000)) chance = 100;
442 /* Apply the saving throw */
443 if (randint0(100) < chance) continue;
445 /* Delete the object */
446 delete_object_idx(i);
454 /* Excise dead objects (backwards!) */
455 for (i = o_max - 1; i >= 1; i--)
459 /* Skip real objects */
460 if (o_ptr->k_idx) continue;
462 /* Move last object into open hole */
463 compact_objects_aux(o_max - 1, i);
465 /* Compress "o_max" */
472 * @brief グローバルオブジェクト配列を初期化する /
473 * Delete all the items when player leaves the level
474 * @note we do NOT visually reflect these (irrelevant) changes
476 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
477 * and the "m_ptr->next_o_idx" field for every monster, since
478 * we know we are clearing every object. Technically, we only
479 * clear those fields for grids/monsters containing objects,
480 * and we clear it once for every such object.
483 void wipe_o_list(void)
487 /* Delete the existing objects */
488 for (i = 1; i < o_max; i++)
490 object_type *o_ptr = &o_list[i];
492 /* Skip dead objects */
493 if (!o_ptr->k_idx) continue;
495 /* Mega-Hack -- preserve artifacts */
496 if (!character_dungeon || preserve_mode)
498 /* Hack -- Preserve unknown artifacts */
499 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
501 /* Mega-Hack -- Preserve the artifact */
502 a_info[o_ptr->name1].cur_num = 0;
507 if (o_ptr->held_m_idx)
512 m_ptr = &m_list[o_ptr->held_m_idx];
514 /* Hack -- see above */
515 m_ptr->hold_o_idx = 0;
523 /* Access location */
524 POSITION y = o_ptr->iy;
525 POSITION x = o_ptr->ix;
530 /* Hack -- see above */
534 /* Wipe the object */
547 * @brief グローバルオブジェクト配列から空きを取得する /
548 * Acquires and returns the index of a "free" object.
549 * @return 開いているオブジェクト要素のID
551 * This routine should almost never fail, but in case it does,
552 * we must be sure to handle "failure" of this routine.
554 OBJECT_IDX o_pop(void)
558 /* Initial allocation */
559 if (o_max < max_o_idx)
564 /* Expand object array */
570 /* Use this object */
575 /* Recycle dead objects */
576 for (i = 1; i < o_max; i++)
583 /* Skip live objects */
584 if (o_ptr->k_idx) continue;
589 /* Use this object */
594 /* Warn the player (except during dungeon creation) */
595 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
603 * @brief オブジェクト生成テーブルに生成制約を加える /
604 * Apply a "object restriction function" to the "object allocation table"
606 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
608 static errr get_obj_num_prep(void)
613 alloc_entry *table = alloc_kind_table;
615 /* Scan the allocation table */
616 for (i = 0; i < alloc_kind_size; i++)
618 /* Accept objects which pass the restriction, if any */
619 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
621 /* Accept this object */
622 table[i].prob2 = table[i].prob1;
625 /* Do not use this object */
628 /* Decline this object */
639 * @brief オブジェクト生成テーブルからアイテムを取得する /
640 * Choose an object kind that seems "appropriate" to the given level
642 * @return 選ばれたオブジェクトベースID
644 * This function uses the "prob2" field of the "object allocation table",\n
645 * and various local information, to calculate the "prob3" field of the\n
646 * same table, which is then used to choose an "appropriate" object, in\n
647 * a relatively efficient manner.\n
649 * It is (slightly) more likely to acquire an object of the given level\n
650 * than one of a lower level. This is done by choosing several objects\n
651 * appropriate to the given level and keeping the "hardest" one.\n
653 * Note that if no objects are "appropriate", then this function will\n
654 * fail, and return zero, but this should *almost* never happen.\n
656 OBJECT_IDX get_obj_num(DEPTH level)
662 alloc_entry *table = alloc_kind_table;
664 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
667 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
669 /* Occasional "boost" */
670 if (one_in_(GREAT_OBJ))
672 /* What a bizarre calculation */
673 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
680 /* Process probabilities */
681 for (i = 0; i < alloc_kind_size; i++)
683 /* Objects are sorted by depth */
684 if (table[i].level > level) break;
689 /* Access the index */
690 k_idx = table[i].index;
692 /* Access the actual kind */
693 k_ptr = &k_info[k_idx];
695 /* Hack -- prevent embedded chests */
696 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
699 table[i].prob3 = table[i].prob2;
702 total += table[i].prob3;
705 /* No legal objects */
706 if (total <= 0) return (0);
710 value = randint0(total);
712 /* Find the object */
713 for (i = 0; i < alloc_kind_size; i++)
715 /* Found the entry */
716 if (value < table[i].prob3) break;
719 value = value - table[i].prob3;
726 /* Try for a "better" object once (50%) or twice (10%) */
733 value = randint0(total);
735 /* Find the object */
736 for (i = 0; i < alloc_kind_size; i++)
738 /* Found the entry */
739 if (value < table[i].prob3) break;
742 value = value - table[i].prob3;
745 /* Keep the "best" one */
746 if (table[i].level < table[j].level) i = j;
749 /* Try for a "better" object twice (10%) */
756 value = randint0(total);
758 /* Find the object */
759 for (i = 0; i < alloc_kind_size; i++)
761 /* Found the entry */
762 if (value < table[i].prob3) break;
765 value = value - table[i].prob3;
768 /* Keep the "best" one */
769 if (table[i].level < table[j].level) i = j;
774 return (table[i].index);
779 * @brief オブジェクトを鑑定済にする /
780 * Known is true when the "attributes" of an object are "known".
781 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
783 * These include tohit, todam, toac, cost, and pval (charges).\n
785 * Note that "knowing" an object gives you everything that an "awareness"\n
786 * gives you, and much more. In fact, the player is always "aware" of any\n
787 * item of which he has full "knowledge".\n
789 * But having full knowledge of, say, one "wand of wonder", does not, by\n
790 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
791 * It happens that most "identify" routines (including "buying from a shop")\n
792 * will make the player "aware" of the object as well as fully "know" it.\n
794 * This routine also removes any inscriptions generated by "feelings".\n
796 void object_known(object_type *o_ptr)
798 /* Remove "default inscriptions" */
799 o_ptr->feeling = FEEL_NONE;
801 /* Clear the "Felt" info */
802 o_ptr->ident &= ~(IDENT_SENSE);
804 /* Clear the "Empty" info */
805 o_ptr->ident &= ~(IDENT_EMPTY);
807 /* Now we know about the item */
808 o_ptr->ident |= (IDENT_KNOWN);
812 * @brief オブジェクトを*鑑定*済にする /
813 * The player is now aware of the effects of the given object.
814 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
817 void object_aware(object_type *o_ptr)
819 bool mihanmei = !object_is_aware(o_ptr);
821 /* Fully aware of the effects */
822 k_info[o_ptr->k_idx].aware = TRUE;
824 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
825 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
829 char o_name[MAX_NLEN];
832 object_copy(q_ptr, o_ptr);
835 object_desc(o_name, q_ptr, OD_NAME_ONLY);
837 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
842 * @brief オブジェクトを試行済にする /
843 * Something has been "sampled"
844 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
847 void object_tried(object_type *o_ptr)
849 /* Mark it as tried (even if "aware") */
850 k_info[o_ptr->k_idx].tried = TRUE;
854 * @brief 重度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 1 (Heavy).
855 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
856 * @return 擬似鑑定結果のIDを返す。
858 byte value_check_aux1(object_type *o_ptr)
861 if (object_is_artifact(o_ptr))
864 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_TERRIBLE;
871 if (object_is_ego(o_ptr))
874 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) return FEEL_WORTHLESS;
877 return FEEL_EXCELLENT;
881 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
884 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
886 if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) return FEEL_AVERAGE;
888 /* Good "armor" bonus */
889 if (o_ptr->to_a > 0) return FEEL_GOOD;
891 /* Good "weapon" bonus */
892 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_GOOD;
894 /* Default to "average" */
899 * @brief 軽度擬似鑑定の判断処理 / Return a "feeling" (or NULL) about an item. Method 2 (Light).
900 * @param o_ptr 擬似鑑定を行うオブジェクトの参照ポインタ。
901 * @return 擬似鑑定結果のIDを返す。
903 byte value_check_aux2(object_type *o_ptr)
905 /* Cursed items (all of them) */
906 if (object_is_cursed(o_ptr)) return FEEL_CURSED;
908 /* Broken items (all of them) */
909 if (object_is_broken(o_ptr)) return FEEL_BROKEN;
911 /* Artifacts -- except cursed/broken ones */
912 if (object_is_artifact(o_ptr)) return FEEL_UNCURSED;
914 /* Ego-Items -- except cursed/broken ones */
915 if (object_is_ego(o_ptr)) return FEEL_UNCURSED;
917 /* Good armor bonus */
918 if (o_ptr->to_a > 0) return FEEL_UNCURSED;
920 /* Good weapon bonuses */
921 if (o_ptr->to_h + o_ptr->to_d > 0) return FEEL_UNCURSED;
928 * @brief 未鑑定なベースアイテムの基本価格を返す /
929 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
930 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
931 * @return オブジェクトの未鑑定価格
933 static s32b object_value_base(object_type *o_ptr)
935 /* Aware item -- use template cost */
936 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
938 /* Analyze the type */
943 case TV_FOOD: return (5L);
945 /* Un-aware Potions */
946 case TV_POTION: return (20L);
948 /* Un-aware Scrolls */
949 case TV_SCROLL: return (20L);
951 /* Un-aware Staffs */
952 case TV_STAFF: return (70L);
955 case TV_WAND: return (50L);
958 case TV_ROD: return (90L);
961 case TV_RING: return (45L);
963 /* Un-aware Amulets */
964 case TV_AMULET: return (45L);
966 /* Figurines, relative to monster level */
969 DEPTH level = r_info[o_ptr->pval].level;
970 if (level < 20) return level*50L;
971 else if (level < 30) return 1000+(level-20)*150L;
972 else if (level < 40) return 2500+(level-30)*350L;
973 else if (level < 50) return 6000+(level-40)*800L;
974 else return 14000+(level-50)*2000L;
978 if (!o_ptr->pval) return 1000L;
979 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
982 /* Paranoia -- Oops */
988 * @brief オブジェクトのフラグ類から価格を算出する /
989 * Return the value of the flags the object has...
990 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
991 * @param plusses フラグに与える価格の基本重み
992 * @return オブジェクトのフラグ価格
994 s32b flag_cost(object_type *o_ptr, int plusses)
997 BIT_FLAGS flgs[TR_FLAG_SIZE];
1001 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1003 object_flags(o_ptr, flgs);
1006 * Exclude fixed flags of the base item.
1007 * pval bonuses of base item will be treated later.
1009 for (i = 0; i < TR_FLAG_SIZE; i++)
1010 flgs[i] &= ~(k_ptr->flags[i]);
1012 /* Exclude fixed flags of the fixed artifact. */
1013 if (object_is_fixed_artifact(o_ptr))
1015 artifact_type *a_ptr = &a_info[o_ptr->name1];
1017 for (i = 0; i < TR_FLAG_SIZE; i++)
1018 flgs[i] &= ~(a_ptr->flags[i]);
1021 /* Exclude fixed flags of the ego-item. */
1022 else if (object_is_ego(o_ptr))
1024 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1026 for (i = 0; i < TR_FLAG_SIZE; i++)
1027 flgs[i] &= ~(e_ptr->flags[i]);
1032 * Calucurate values of remaining flags
1034 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
1035 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
1036 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
1037 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
1038 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
1039 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
1040 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
1041 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
1042 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
1043 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
1044 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
1045 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
1046 total += (10000 + (2500 * plusses));
1047 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
1048 total += (10000 + (2500 * plusses));
1052 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
1053 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
1054 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
1055 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
1056 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
1057 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
1058 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
1059 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
1060 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
1061 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
1062 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
1063 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
1064 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
1065 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
1066 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
1067 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
1068 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
1069 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
1070 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
1071 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
1072 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
1074 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
1075 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
1076 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
1077 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
1078 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
1079 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
1080 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
1081 total += (tmp_cost * count);
1083 if (have_flag(flgs, TR_SUST_STR)) total += 850;
1084 if (have_flag(flgs, TR_SUST_INT)) total += 850;
1085 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
1086 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
1087 if (have_flag(flgs, TR_SUST_CON)) total += 850;
1088 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
1089 if (have_flag(flgs, TR_RIDING)) total += 0;
1090 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1091 if (have_flag(flgs, TR_THROW)) total += 5000;
1092 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1093 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1097 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1098 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1099 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1100 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1101 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1102 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1103 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1104 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1105 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1106 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1107 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1108 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1109 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1110 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1111 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1112 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1113 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1114 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1115 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1116 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1117 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1118 total += (tmp_cost * count);
1120 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1121 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1122 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1123 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1124 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1125 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1126 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1127 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1128 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1129 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1130 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1131 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1132 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1133 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1134 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1135 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1136 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1137 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1138 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1139 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1140 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1141 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1142 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1143 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1144 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1145 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1146 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1147 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1148 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1149 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1150 if (have_flag(flgs, TR_REGEN)) total += 2500;
1151 if (have_flag(flgs, TR_WARNING)) total += 2000;
1152 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1153 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1154 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1155 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1156 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1157 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1158 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1159 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1160 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1161 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1162 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1163 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1164 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1165 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1166 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1167 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1168 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1169 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1170 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1171 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1172 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1173 if (have_flag(flgs, TR_TELEPORT))
1175 if (object_is_cursed(o_ptr))
1180 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1181 if (have_flag(flgs, TR_BLESSED)) total += 750;
1182 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1183 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1184 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1185 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1186 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1188 /* Also, give some extra for activatable powers... */
1189 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1191 const activation_type* const act_ptr = find_activation_info(o_ptr);
1193 total += act_ptr->value;
1202 * @brief オブジェクトの真の価格を算出する /
1203 * Return the value of the flags the object has...
1204 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1205 * @return オブジェクトの本価格
1207 * Return the "real" price of a "known" item, not including discounts\n
1209 * Wand and staffs get cost for each charge\n
1211 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1213 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1215 * Missiles are only worth 5 gold per bonus point, since they\n
1216 * usually appear in groups of 20, and we want the player to get\n
1217 * the same amount of cash for any "equivalent" item. Note that\n
1218 * missiles never have any of the "pval" flags, and in fact, they\n
1219 * only have a few of the available flags, primarily of the "slay"\n
1220 * and "brand" and "ignore" variety.\n
1222 * Armor with a negative armor bonus is worthless.\n
1223 * Weapons with negative hit+damage bonuses are worthless.\n
1225 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1227 PRICE object_value_real(object_type *o_ptr)
1230 BIT_FLAGS flgs[TR_FLAG_SIZE];
1231 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1234 /* Hack -- "worthless" items */
1235 if (!k_info[o_ptr->k_idx].cost) return (0L);
1238 value = k_info[o_ptr->k_idx].cost;
1240 /* Extract some flags */
1241 object_flags(o_ptr, flgs);
1244 if (object_is_fixed_artifact(o_ptr))
1246 artifact_type *a_ptr = &a_info[o_ptr->name1];
1248 /* Hack -- "worthless" artifacts */
1249 if (!a_ptr->cost) return (0L);
1251 /* Hack -- Use the artifact cost instead */
1252 value = a_ptr->cost;
1253 value += flag_cost(o_ptr, o_ptr->pval);
1255 /* Don't add pval bonuses etc. */
1260 else if (object_is_ego(o_ptr))
1262 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1264 /* Hack -- "worthless" ego-items */
1265 if (!e_ptr->cost) return (0L);
1267 /* Hack -- Reward the ego-item with a bonus */
1268 value += e_ptr->cost;
1269 value += flag_cost(o_ptr, o_ptr->pval);
1277 for (i = 0; i < TR_FLAG_SIZE; i++)
1278 if (o_ptr->art_flags[i]) flag = TRUE;
1280 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1283 /* Analyze pval bonus for normal object */
1284 switch (o_ptr->tval)
1307 if (!o_ptr->pval) break;
1309 /* Hack -- Negative "pval" is always bad */
1310 if (o_ptr->pval < 0) return (0L);
1312 /* Give credit for stat bonuses */
1313 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1314 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1315 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1316 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1317 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1318 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1320 /* Give credit for stealth and searching */
1321 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1322 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1323 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1325 /* Give credit for infra-vision and tunneling */
1326 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1327 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1329 /* Give credit for extra attacks */
1330 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1332 /* Give credit for speed bonus */
1333 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1339 /* Analyze the item */
1340 switch (o_ptr->tval)
1345 /* Pay extra for charges, depending on standard number of
1346 * charges. Handle new-style wands correctly. -LM-
1348 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1355 /* Pay extra for charges, depending on standard number of
1358 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1368 /* Hack -- negative bonuses are bad */
1369 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1371 /* Give credit for bonuses */
1372 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1389 /* Hack -- negative armor bonus */
1390 if (o_ptr->to_a < 0) return (0L);
1392 /* Give credit for bonuses */
1393 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1406 /* Hack -- negative hit/damage bonuses */
1407 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1409 /* Factor in the bonuses */
1410 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1412 /* Hack -- Factor in extra damage dice and sides */
1413 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1414 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1425 /* Hack -- negative hit/damage bonuses */
1426 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1428 /* Factor in the bonuses */
1429 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1431 /* Hack -- Factor in extra damage dice and sides */
1432 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1433 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1439 /* Figurines, relative to monster level */
1442 DEPTH level = r_info[o_ptr->pval].level;
1443 if (level < 20) value = level*50L;
1444 else if (level < 30) value = 1000+(level-20)*150L;
1445 else if (level < 40) value = 2500+(level-30)*350L;
1446 else if (level < 50) value = 6000+(level-40)*800L;
1447 else value = 14000+(level-50)*2000L;
1453 if (!o_ptr->pval) value = 1000L;
1454 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1460 if (!o_ptr->pval) value = 0L;
1465 /* Worthless object */
1466 if (value < 0) return 0L;
1468 /* Return the value */
1474 * @brief オブジェクト価格算出のメインルーチン /
1475 * Return the price of an item including plusses (and charges)
1476 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1477 * @return オブジェクトの判明している現価格
1479 * This function returns the "value" of the given item (qty one)\n
1481 * Never notice "unknown" bonuses or properties, including "curses",\n
1482 * since that would give the player information he did not have.\n
1484 * Note that discounted items stay discounted forever, even if\n
1485 * the discount is "forgotten" by the player via memory loss.\n
1487 PRICE object_value(object_type *o_ptr)
1491 /* Unknown items -- acquire a base value */
1492 if (object_is_known(o_ptr))
1494 /* Broken items -- worthless */
1495 if (object_is_broken(o_ptr)) return (0L);
1497 /* Cursed items -- worthless */
1498 if (object_is_cursed(o_ptr)) return (0L);
1500 /* Real value (see above) */
1501 value = object_value_real(o_ptr);
1504 /* Known items -- acquire the actual value */
1507 /* Hack -- Felt broken items */
1508 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1510 /* Hack -- Felt cursed items */
1511 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1513 /* Base value (see above) */
1514 value = object_value_base(o_ptr);
1518 /* Apply discount (if any) */
1519 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1522 /* Return the final value */
1529 * @brief 破壊可能なアイテムかを返す /
1530 * Determines whether an object can be destroyed, and makes fake inscription.
1531 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1532 * @return オブジェクトが破壊可能ならばTRUEを返す
1534 bool can_player_destroy_object(object_type *o_ptr)
1536 /* Artifacts cannot be destroyed */
1537 if (!object_is_artifact(o_ptr)) return TRUE;
1539 /* If object is unidentified, makes fake inscription */
1540 if (!object_is_known(o_ptr))
1542 byte feel = FEEL_SPECIAL;
1544 /* Hack -- Handle icky artifacts */
1545 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1547 /* Hack -- inscribe the artifact */
1548 o_ptr->feeling = feel;
1550 /* We have "felt" it (again) */
1551 o_ptr->ident |= (IDENT_SENSE);
1553 /* Combine the pack */
1554 p_ptr->notice |= (PN_COMBINE);
1557 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1563 /* Identified artifact -- Nothing to do */
1569 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1570 * Distribute charges of rods or wands.
1571 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1572 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1573 * @param amt 分割したい回数量 number of items that are transfered
1576 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1577 * charges need to be allocated between the two stacks. If all the items\n
1578 * are being dropped, it makes for a neater message to leave the original\n
1579 * stack's pval alone. -LM-\n
1581 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1583 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1585 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1586 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1588 /* Hack -- Rods also need to have their timeouts distributed. The
1589 * dropped stack will accept all time remaining to charge up to its
1592 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1594 if (q_ptr->pval > o_ptr->timeout)
1595 q_ptr->timeout = o_ptr->timeout;
1597 q_ptr->timeout = q_ptr->pval;
1599 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1605 * @brief 魔法棒やロッドの使用回数を減らす /
1606 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1607 * @param amt 減らしたい回数量 number of items that are transfered
1610 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1611 * charges of the stack needs to be reduced, unless all the items are\n
1612 * being destroyed. -LM-\n
1614 void reduce_charges(object_type *o_ptr, int amt)
1616 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1617 (amt < o_ptr->number))
1619 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1624 * Determine if an item can "absorb" a second item
1626 * See "object_absorb()" for the actual "absorption" code.
1628 * If permitted, we allow staffs (if they are known to have equal charges
1629 * and both are either known or confirmed empty) and wands (if both are
1630 * either known or confirmed empty) and rods (in all cases) to combine.
1631 * Staffs will unstack (if necessary) when they are used, but wands and
1632 * rods will only unstack if one is dropped. -LM-
1634 * If permitted, we allow weapons/armor to stack, if fully "known".
1636 * Missiles will combine if both stacks have the same "known" status.
1637 * This is done to make unidentified stacks of missiles useful.
1639 * Food, potions, scrolls, and "easy know" items always stack.
1641 * Chests, and activatable items, never stack (for various reasons).
1645 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1647 #define MAX_STACK_SIZE 99
1651 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1652 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1653 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1654 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1655 * @return 重ね合わせ可能なアイテム数
1657 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1661 /* Default maximum number of stack */
1662 int max_num = MAX_STACK_SIZE;
1664 /* Require identical object types */
1665 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1668 /* Analyze the items */
1669 switch (o_ptr->tval)
1671 /* Chests and Statues*/
1682 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1683 if (o_ptr->pval != j_ptr->pval) return 0;
1687 /* Figurines and Corpses*/
1692 if (o_ptr->pval != j_ptr->pval) return 0;
1698 /* Food and Potions and Scrolls */
1710 /* Require either knowledge or known empty for both staffs. */
1711 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1712 !object_is_known(o_ptr)) ||
1713 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1714 !object_is_known(j_ptr))) return 0;
1716 /* Require identical charges, since staffs are bulky. */
1717 if (o_ptr->pval != j_ptr->pval) return 0;
1726 /* Require either knowledge or known empty for both wands. */
1727 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1728 !object_is_known(o_ptr)) ||
1729 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1730 !object_is_known(j_ptr))) return 0;
1732 /* Wand charges combine in O&ZAngband. */
1738 /* Staffs and Wands and Rods */
1741 /* Prevent overflaw of timeout */
1742 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1748 /* Weapons and Armor */
1764 /* Rings, Amulets, Lites */
1770 /* Require full knowledge of both items */
1771 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1781 /* Require identical knowledge of both items */
1782 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1783 if (o_ptr->feeling != j_ptr->feeling) return 0;
1785 /* Require identical "bonuses" */
1786 if (o_ptr->to_h != j_ptr->to_h) return 0;
1787 if (o_ptr->to_d != j_ptr->to_d) return 0;
1788 if (o_ptr->to_a != j_ptr->to_a) return 0;
1790 /* Require identical "pval" code */
1791 if (o_ptr->pval != j_ptr->pval) return 0;
1793 /* Artifacts never stack */
1794 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1796 /* Require identical "ego-item" names */
1797 if (o_ptr->name2 != j_ptr->name2) return 0;
1799 /* Require identical added essence */
1800 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1801 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1803 /* Hack -- Never stack "powerful" items */
1804 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1806 /* Hack -- Never stack recharging items */
1807 if (o_ptr->timeout || j_ptr->timeout) return 0;
1809 /* Require identical "values" */
1810 if (o_ptr->ac != j_ptr->ac) return 0;
1811 if (o_ptr->dd != j_ptr->dd) return 0;
1812 if (o_ptr->ds != j_ptr->ds) return 0;
1821 /* Require knowledge */
1822 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1830 /* Hack -- Identical art_flags! */
1831 for (i = 0; i < TR_FLAG_SIZE; i++)
1832 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1834 /* Hack -- Require identical "cursed" status */
1835 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1837 /* Hack -- Require identical "broken" status */
1838 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1841 /* Hack -- require semi-matching "inscriptions" */
1842 if (o_ptr->inscription && j_ptr->inscription &&
1843 (o_ptr->inscription != j_ptr->inscription))
1846 /* Hack -- normally require matching "inscriptions" */
1847 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1849 /* Hack -- normally require matching "discounts" */
1850 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1853 /* They match, so they must be similar */
1858 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1859 * Determine if an item can absorb a second item.
1860 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1861 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1862 * @return 重ね合わせ可能ならばTRUEを返す。
1864 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1866 int total = o_ptr->number + j_ptr->number;
1869 /* Are these objects similar? */
1870 max_num = object_similar_part(o_ptr, j_ptr);
1872 /* Return if not similar */
1873 if (!max_num) return FALSE;
1875 /* Maximal "stacking" limit */
1876 if (total > max_num) return (0);
1879 /* They match, so they must be similar */
1885 * @brief 両オブジェクトをスロットに重ね合わせる。
1886 * Allow one item to "absorb" another, assuming they are similar
1887 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1888 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1891 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1893 int max_num = object_similar_part(o_ptr, j_ptr);
1894 int total = o_ptr->number + j_ptr->number;
1895 int diff = (total > max_num) ? total - max_num : 0;
1897 /* Combine quantity, lose excess items */
1898 o_ptr->number = (total > max_num) ? max_num : total;
1900 /* Hack -- blend "known" status */
1901 if (object_is_known(j_ptr)) object_known(o_ptr);
1903 /* Hack -- clear "storebought" if only one has it */
1904 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1905 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1907 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1908 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1911 /* Hack -- blend "mental" status */
1912 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1914 /* Hack -- blend "inscriptions" */
1915 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1917 /* Hack -- blend "feelings" */
1918 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1920 /* Hack -- could average discounts XXX XXX XXX */
1921 /* Hack -- save largest discount XXX XXX XXX */
1922 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1924 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1925 if (o_ptr->tval == TV_ROD)
1927 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1928 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1931 /* Hack -- if wands are stacking, combine the charges. -LM- */
1932 if (o_ptr->tval == TV_WAND)
1934 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1940 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1941 * Find the index of the object_kind with the given tval and sval
1942 * @param tval 検索したいベースアイテムのtval
1943 * @param sval 検索したいベースアイテムのsval
1946 IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
1953 for (k = 1; k < max_k_idx; k++)
1955 object_kind *k_ptr = &k_info[k];
1957 /* Require correct tval */
1958 if (k_ptr->tval != tval) continue;
1961 if (k_ptr->sval == sval) return (k);
1963 /* Ignore illegal items */
1964 if (sval != SV_ANY) continue;
1966 /* Apply the randomizer */
1967 if (!one_in_(++num)) continue;
1969 /* Use this value */
1973 /* Return this choice */
1981 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1991 * @brief オブジェクトを初期化する
1992 * Wipe an object clean.
1993 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1996 void object_wipe(object_type *o_ptr)
1998 /* Wipe the structure */
1999 (void)WIPE(o_ptr, object_type);
2004 * @brief オブジェクトを複製する
2005 * Wipe an object clean.
2006 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
2007 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
2010 void object_copy(object_type *o_ptr, object_type *j_ptr)
2012 /* Copy the structure */
2013 (void)COPY(o_ptr, j_ptr, object_type);
2018 * @brief オブジェクト構造体にベースアイテムを作成する
2019 * Prepare an object based on an object kind.
2020 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
2021 * @param k_idx 新たに作成したいベースアイテム情報のID
2024 void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
2026 object_kind *k_ptr = &k_info[k_idx];
2028 /* Clear the record */
2031 /* Save the kind index */
2032 o_ptr->k_idx = k_idx;
2034 /* Efficiency -- tval/sval */
2035 o_ptr->tval = k_ptr->tval;
2036 o_ptr->sval = k_ptr->sval;
2038 /* Default "pval" */
2039 o_ptr->pval = k_ptr->pval;
2041 /* Default number */
2044 /* Default weight */
2045 o_ptr->weight = k_ptr->weight;
2048 o_ptr->to_h = k_ptr->to_h;
2049 o_ptr->to_d = k_ptr->to_d;
2050 o_ptr->to_a = k_ptr->to_a;
2053 o_ptr->ac = k_ptr->ac;
2054 o_ptr->dd = k_ptr->dd;
2055 o_ptr->ds = k_ptr->ds;
2057 /* Default activation */
2058 if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx;
2060 /* Hack -- worthless items are always "broken" */
2061 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
2063 /* Hack -- cursed items are always "cursed" */
2064 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
2065 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2066 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
2067 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
2068 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
2069 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
2074 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
2075 * Help determine an "enchantment bonus" for an object.
2076 * @param max ボーナス値の限度
2077 * @param level ボーナス値に加味する基準生成階
2078 * @return 算出されたボーナス値
2080 * To avoid floating point but still provide a smooth distribution of bonuses,\n
2081 * we simply round the results of division in such a way as to "average" the\n
2082 * correct floating point value.\n
2084 * This function has been changed. It uses "randnor()" to choose values from\n
2085 * a normal distribution, whose mean moves from zero towards the max as the\n
2086 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2087 * and whose values are forced to lie between zero and the max, inclusive.\n
2089 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2090 * rare to get the "full" enchantment on an object, even a deep levels.\n
2092 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2094 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2096 * N 0 1 2 3 4 5 6 7 8 9 10\n
2097 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2098 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2099 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2100 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2101 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2102 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2103 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2104 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2105 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2106 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2107 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2108 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2109 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2110 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2111 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2112 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2113 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2114 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2116 int m_bonus(int max, DEPTH level)
2118 int bonus, stand, extra, value;
2121 /* Paranoia -- enforce maximal "level" */
2122 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2125 /* The "bonus" moves towards the max */
2126 bonus = ((max * level) / MAX_DEPTH);
2128 /* Hack -- determine fraction of error */
2129 extra = ((max * level) % MAX_DEPTH);
2131 /* Hack -- simulate floating point computations */
2132 if (randint0(MAX_DEPTH) < extra) bonus++;
2135 /* The "stand" is equal to one quarter of the max */
2138 /* Hack -- determine fraction of error */
2141 /* Hack -- simulate floating point computations */
2142 if (randint0(4) < extra) stand++;
2145 /* Choose an "interesting" value */
2146 value = randnor(bonus, stand);
2148 /* Enforce the minimum value */
2149 if (value < 0) return (0);
2151 /* Enforce the maximum value */
2152 if (value > max) return (max);
2160 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2161 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2164 static void object_mention(object_type *o_ptr)
2166 char o_name[MAX_NLEN];
2168 object_aware(o_ptr);
2169 object_known(o_ptr);
2171 /* Mark the item as fully known */
2172 o_ptr->ident |= (IDENT_MENTAL);
2175 object_desc(o_name, o_ptr, 0);
2176 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2180 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2181 * Mega-Hack -- Attempt to create one of the "Special Objects"
2182 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2183 * @return 生成に成功したらTRUEを返す。
2185 * We are only called from "make_object()", and we assume that\n
2186 * "apply_magic()" is called immediately after we return.\n
2188 * Note -- see "make_artifact()" and "apply_magic()"\n
2190 static bool make_artifact_special(object_type *o_ptr)
2195 /*! @note 地上ではキャンセルする / No artifacts in the town */
2196 if (!dun_level) return (FALSE);
2198 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2199 if (get_obj_num_hook) return (FALSE);
2201 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2202 for (i = 0; i < max_a_idx; i++)
2204 artifact_type *a_ptr = &a_info[i];
2206 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2207 if (!a_ptr->name) continue;
2209 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2210 if (a_ptr->cur_num) continue;
2211 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2212 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2214 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2215 * XXX XXX Enforce minimum "depth" (loosely) */
2216 if (a_ptr->level > object_level)
2218 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2219 int d = (a_ptr->level - object_level) * 2;
2220 if (!one_in_(d)) continue;
2223 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2224 if (!one_in_(a_ptr->rarity)) continue;
2226 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2227 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2228 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2229 if (k_info[k_idx].level > object_level)
2231 int d = (k_info[k_idx].level - object_level) * 5;
2232 if (!one_in_(d)) continue;
2235 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2236 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2237 object_prep(o_ptr, k_idx);
2240 random_artifact_resistance(o_ptr, a_ptr);
2244 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2250 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2251 * Mega-Hack -- Attempt to create one of the "Special Objects"
2252 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2253 * @return 生成に成功したらTRUEを返す。
2255 * Attempt to change an object into an artifact\n
2256 * This routine should only be called by "apply_magic()"\n
2257 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2259 static bool make_artifact(object_type *o_ptr)
2264 /* No artifacts in the town */
2265 if (!dun_level) return (FALSE);
2267 /* Paranoia -- no "plural" artifacts */
2268 if (o_ptr->number != 1) return (FALSE);
2270 /* Check the artifact list (skip the "specials") */
2271 for (i = 0; i < max_a_idx; i++)
2273 artifact_type *a_ptr = &a_info[i];
2275 /* Skip "empty" items */
2276 if (!a_ptr->name) continue;
2278 /* Cannot make an artifact twice */
2279 if (a_ptr->cur_num) continue;
2281 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2283 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2285 /* Must have the correct fields */
2286 if (a_ptr->tval != o_ptr->tval) continue;
2287 if (a_ptr->sval != o_ptr->sval) continue;
2289 /* XXX XXX Enforce minimum "depth" (loosely) */
2290 if (a_ptr->level > dun_level)
2292 /* Acquire the "out-of-depth factor" */
2293 int d = (a_ptr->level - dun_level) * 2;
2295 /* Roll for out-of-depth creation */
2296 if (!one_in_(d)) continue;
2299 /* We must make the "rarity roll" */
2300 if (!one_in_(a_ptr->rarity)) continue;
2302 /* Hack -- mark the item as an artifact */
2305 /* Hack: Some artifacts get random extra powers */
2306 random_artifact_resistance(o_ptr, a_ptr);
2318 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2319 * Choose random ego type
2320 * @param slot 取得したいエゴの装備部位
2321 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2322 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2324 static byte get_random_ego(byte slot, bool good)
2327 ego_item_type *e_ptr;
2331 for (i = 1; i < max_e_idx; i++)
2335 if (e_ptr->slot == slot
2336 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2339 total += (255 / e_ptr->rarity);
2343 value = randint1(total);
2345 for (i = 1; i < max_e_idx; i++)
2349 if (e_ptr->slot == slot
2350 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2353 value -= (255 / e_ptr->rarity);
2354 if (value <= 0L) break;
2362 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2363 * Apply magic to an item known to be a "weapon"
2364 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2365 * @param level 生成基準階
2366 * @param power 生成ランク
2369 * Hack -- note special base damage dice boosting\n
2370 * Hack -- note special processing for weapon/digger\n
2372 static void a_m_aux_1(object_type *o_ptr, DEPTH level, int power)
2374 HIT_PROB tohit1 = randint1(5) + (HIT_PROB)m_bonus(5, level);
2375 HIT_POINT todam1 = randint1(5) + (HIT_POINT)m_bonus(5, level);
2377 HIT_PROB tohit2 = (HIT_PROB)m_bonus(10, level);
2378 HIT_POINT todam2 = (HIT_POINT)m_bonus(10, level);
2380 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2382 tohit2 = (tohit2+1)/2;
2383 todam2 = (todam2+1)/2;
2390 o_ptr->to_h += tohit1;
2391 o_ptr->to_d += todam1;
2397 o_ptr->to_h += tohit2;
2398 o_ptr->to_d += todam2;
2406 o_ptr->to_h -= tohit1;
2407 o_ptr->to_d -= todam1;
2412 /* Penalize again */
2413 o_ptr->to_h -= tohit2;
2414 o_ptr->to_d -= todam2;
2417 /* Cursed (if "bad") */
2418 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2421 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2424 switch (o_ptr->tval)
2431 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2432 create_artifact(o_ptr, FALSE);
2434 /* Special Ego-item */
2435 o_ptr->name2 = EGO_DIGGING;
2439 else if (power < -1)
2441 /* Hack -- Horrible digging bonus */
2442 o_ptr->pval = 0 - (5 + randint1(5));
2448 /* Hack -- Reverse digging bonus */
2449 o_ptr->pval = 0 - (o_ptr->pval);
2463 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2465 create_artifact(o_ptr, FALSE);
2470 /* Roll for an ego-item */
2471 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2472 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2474 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2476 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2481 switch (o_ptr->name2)
2484 if (one_in_(4) && (level > 40))
2485 add_flag(o_ptr->art_flags, TR_BLOWS);
2489 add_flag(o_ptr->art_flags, TR_RES_POIS);
2491 add_flag(o_ptr->art_flags, TR_WARNING);
2493 case EGO_KILL_DRAGON:
2495 add_flag(o_ptr->art_flags, TR_RES_POIS);
2499 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2501 case EGO_SLAYING_WEAPON:
2502 if (one_in_(3)) /* double damage */
2510 while (one_in_(o_ptr->dd));
2516 while (one_in_(o_ptr->ds));
2521 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2523 if (o_ptr->tval == TV_SWORD && one_in_(3))
2525 add_flag(o_ptr->art_flags, TR_VORPAL);
2530 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2536 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2538 add_flag(o_ptr->art_flags, TR_DEX);
2540 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2543 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, level) + 1;
2545 case EGO_EARTHQUAKES:
2546 if (one_in_(3) && (level > 60))
2547 add_flag(o_ptr->art_flags, TR_BLOWS);
2549 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, level);
2553 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2557 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2559 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2561 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2562 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2565 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2566 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2567 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2568 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2572 if (!o_ptr->art_name)
2574 /* Hack -- Super-charge the damage dice */
2575 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2577 /* Hack -- Lower the damage dice */
2578 if (o_ptr->dd > 9) o_ptr->dd = 9;
2583 else if (power < -1)
2585 /* Roll for ego-item */
2586 if (randint0(MAX_DEPTH) < level)
2590 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2591 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2597 switch (o_ptr->name2)
2600 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2601 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2603 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2604 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2605 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2606 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2607 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2608 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2622 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2624 create_artifact(o_ptr, FALSE);
2627 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2641 if (power > 2) /* power > 2 is debug only */
2643 create_artifact(o_ptr, FALSE);
2647 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2649 switch (o_ptr->name2)
2651 case EGO_SLAYING_BOLT:
2656 /* Hack -- super-charge the damage dice */
2657 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2659 /* Hack -- restrict the damage dice */
2660 if (o_ptr->dd > 9) o_ptr->dd = 9;
2664 else if (power < -1)
2666 /* Roll for ego-item */
2667 if (randint0(MAX_DEPTH) < level)
2669 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2679 * @brief ドラゴン装備にランダムな耐性を与える
2680 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2683 static void dragon_resist(object_type * o_ptr)
2688 one_dragon_ele_resistance(o_ptr);
2690 one_high_resistance(o_ptr);
2696 * @brief オブジェクトにランダムな強いESPを与える
2697 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2700 static bool add_esp_strong(object_type *o_ptr)
2702 bool nonliv = FALSE;
2704 switch (randint1(3))
2706 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2707 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2708 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2715 * @brief オブジェクトにランダムな弱いESPを与える
2716 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2717 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2720 static void add_esp_weak(object_type *o_ptr, bool extra)
2723 u32b weak_esp_list[] = {
2735 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2736 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2738 /* Add unduplicated weak esp flags randomly */
2739 for (i = 0; i < add_count; ++ i)
2741 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2743 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2744 weak_esp_list[choice] = weak_esp_list[i];
2750 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2751 * Apply magic to an item known to be "armor"
2752 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2753 * @param level 生成基準階
2754 * @param power 生成ランク
2757 * Hack -- note special processing for crown/helm\n
2758 * Hack -- note special processing for robe of permanence\n
2760 static void a_m_aux_2(object_type *o_ptr, DEPTH level, int power)
2762 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
2763 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
2769 o_ptr->to_a += toac1;
2775 o_ptr->to_a += toac2;
2783 o_ptr->to_a -= toac1;
2788 /* Penalize again */
2789 o_ptr->to_a -= toac2;
2792 /* Cursed (if "bad") */
2793 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2798 switch (o_ptr->tval)
2802 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2803 create_artifact(o_ptr, FALSE);
2813 /* Hack -- Try for "Robes of the Magi" */
2814 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2815 (o_ptr->sval == SV_ROBE) &&
2816 (randint0(100) < 15))
2820 o_ptr->name2 = EGO_YOIYAMI;
2821 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2822 o_ptr->sval = SV_YOIYAMI_ROBE;
2828 o_ptr->name2 = EGO_PERMANENCE;
2833 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2835 create_artifact(o_ptr, FALSE);
2841 bool okay_flag = TRUE;
2843 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2845 switch (o_ptr->name2)
2848 if (o_ptr->tval != TV_HARD_ARMOR)
2854 if (o_ptr->tval != TV_SOFT_ARMOR)
2863 if (okay_flag) break;
2865 switch (o_ptr->name2)
2867 case EGO_RESISTANCE:
2869 add_flag(o_ptr->art_flags, TR_RES_POIS);
2872 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2873 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2877 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2879 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2881 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2882 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2884 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2885 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2886 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2887 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2888 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2889 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2890 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2891 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2894 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2895 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2896 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2897 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2898 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2899 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2912 if (o_ptr->sval == SV_DRAGON_SHIELD)
2914 dragon_resist(o_ptr);
2915 if (!one_in_(3)) break;
2921 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2923 create_artifact(o_ptr, FALSE);
2929 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2930 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2931 && o_ptr->name2 == EGO_S_DWARVEN)
2938 switch (o_ptr->name2)
2941 if (!one_in_(3)) one_high_resistance(o_ptr);
2942 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2944 case EGO_REFLECTION:
2945 if (o_ptr->sval == SV_MIRROR_SHIELD)
2950 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2951 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2960 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2962 dragon_resist(o_ptr);
2963 if (!one_in_(3)) break;
2967 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2969 create_artifact(o_ptr, FALSE);
2972 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2976 else if (power < -1)
2978 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2986 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2988 dragon_resist(o_ptr);
2989 if (!one_in_(3)) break;
2994 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2996 create_artifact(o_ptr, FALSE);
2999 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
3001 switch (o_ptr->name2)
3003 case EGO_SLOW_DESCENT:
3006 one_high_resistance(o_ptr);
3012 else if (power < -1)
3014 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
3025 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3027 create_artifact(o_ptr, FALSE);
3032 bool ok_flag = TRUE;
3033 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3035 switch (o_ptr->name2)
3038 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
3039 else add_esp_weak(o_ptr, FALSE);
3043 case EGO_REGENERATION:
3044 case EGO_LORDLINESS:
3050 if (one_in_(2)) add_esp_strong(o_ptr);
3051 else add_esp_weak(o_ptr, FALSE);
3054 default:/* not existing crown (wisdom,lite, etc...) */
3058 break; /* while (1) */
3064 else if (power < -1)
3068 bool ok_flag = TRUE;
3069 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3071 switch (o_ptr->name2)
3073 case EGO_ANCIENT_CURSE:
3074 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3075 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3076 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3077 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3078 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3079 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3083 break; /* while (1) */
3092 if (o_ptr->sval == SV_DRAGON_HELM)
3094 dragon_resist(o_ptr);
3095 if (!one_in_(3)) break;
3101 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3103 create_artifact(o_ptr, FALSE);
3108 bool ok_flag = TRUE;
3109 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3111 switch (o_ptr->name2)
3113 case EGO_BRILLIANCE:
3115 case EGO_INFRAVISION:
3116 case EGO_H_PROTECTION:
3121 if (one_in_(2)) add_esp_strong(o_ptr);
3122 else add_esp_weak(o_ptr, FALSE);
3126 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3127 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3130 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3132 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3134 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3135 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3137 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3138 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3139 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3140 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3141 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3142 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3143 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3144 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3146 default:/* not existing helm (Magi, Might, etc...)*/
3150 break; /* while (1) */
3155 else if (power < -1)
3159 bool ok_flag = TRUE;
3160 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3162 switch (o_ptr->name2)
3164 case EGO_ANCIENT_CURSE:
3168 break; /* while (1) */
3179 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3181 create_artifact(o_ptr, FALSE);
3184 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3186 switch (o_ptr->name2)
3195 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3196 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3197 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3198 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3205 else if (power < -1)
3207 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3218 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3219 * Apply magic to an item known to be a "ring" or "amulet"
3220 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3221 * @param level 生成基準階
3222 * @param power 生成ランク
3225 * Hack -- note special "pval boost" code for ring of speed\n
3226 * Hack -- note that some items must be cursed (or blessed)\n
3228 static void a_m_aux_3(object_type *o_ptr, DEPTH level, int power)
3230 /* Apply magic (good or bad) according to type */
3231 switch (o_ptr->tval)
3236 switch (o_ptr->sval)
3238 case SV_RING_ATTACKS:
3241 o_ptr->pval = (PARAMETER_VALUE)m_bonus(2, level);
3242 if (one_in_(15)) o_ptr->pval++;
3243 if (o_ptr->pval < 1) o_ptr->pval = 1;
3249 o_ptr->ident |= (IDENT_BROKEN);
3252 o_ptr->curse_flags |= TRC_CURSED;
3255 o_ptr->pval = 0 - (o_ptr->pval);
3266 /* Strength, Constitution, Dexterity, Intelligence */
3272 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3278 o_ptr->ident |= (IDENT_BROKEN);
3281 o_ptr->curse_flags |= TRC_CURSED;
3284 o_ptr->pval = 0 - (o_ptr->pval);
3290 /* Ring of Speed! */
3293 /* Base speed (1 to 10) */
3294 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3296 /* Super-charge the ring */
3297 while (randint0(100) < 50) o_ptr->pval++;
3303 o_ptr->ident |= (IDENT_BROKEN);
3306 o_ptr->curse_flags |= TRC_CURSED;
3309 o_ptr->pval = 0 - (o_ptr->pval);
3317 case SV_RING_LORDLY:
3321 one_lordly_high_resistance(o_ptr);
3325 /* Bonus to armor class */
3326 o_ptr->to_a = 10 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3330 case SV_RING_WARNING:
3332 if (one_in_(3)) one_low_esp(o_ptr);
3337 case SV_RING_SEARCHING:
3339 /* Bonus to searching */
3340 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3346 o_ptr->ident |= (IDENT_BROKEN);
3349 o_ptr->curse_flags |= TRC_CURSED;
3352 o_ptr->pval = 0 - (o_ptr->pval);
3358 /* Flames, Acid, Ice */
3359 case SV_RING_FLAMES:
3364 /* Bonus to armor class */
3365 o_ptr->to_a = 5 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3369 /* Weakness, Stupidity */
3370 case SV_RING_WEAKNESS:
3371 case SV_RING_STUPIDITY:
3374 o_ptr->ident |= (IDENT_BROKEN);
3377 o_ptr->curse_flags |= TRC_CURSED;
3380 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3381 if (power > 0) power = 0 - power;
3386 /* WOE, Stupidity */
3390 o_ptr->ident |= (IDENT_BROKEN);
3393 o_ptr->curse_flags |= TRC_CURSED;
3396 o_ptr->to_a = 0 - (5 + (ARMOUR_CLASS)m_bonus(10, level));
3397 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3398 if (power > 0) power = 0 - power;
3403 /* Ring of damage */
3404 case SV_RING_DAMAGE:
3406 /* Bonus to damage */
3407 o_ptr->to_d = 1 + randint1(5) + (HIT_POINT)m_bonus(16, level);
3413 o_ptr->ident |= (IDENT_BROKEN);
3416 o_ptr->curse_flags |= TRC_CURSED;
3419 o_ptr->to_d = 0 - o_ptr->to_d;
3425 /* Ring of Accuracy */
3426 case SV_RING_ACCURACY:
3429 o_ptr->to_h = 1 + randint1(5) + (HIT_PROB)m_bonus(16, level);
3435 o_ptr->ident |= (IDENT_BROKEN);
3438 o_ptr->curse_flags |= TRC_CURSED;
3441 o_ptr->to_h = 0 - o_ptr->to_h;
3447 /* Ring of Protection */
3448 case SV_RING_PROTECTION:
3450 /* Bonus to armor class */
3451 o_ptr->to_a = 5 + randint1(8) + (ARMOUR_CLASS)m_bonus(10, level);
3457 o_ptr->ident |= (IDENT_BROKEN);
3460 o_ptr->curse_flags |= TRC_CURSED;
3463 o_ptr->to_a = 0 - o_ptr->to_a;
3469 /* Ring of Slaying */
3470 case SV_RING_SLAYING:
3472 /* Bonus to damage and to hit */
3473 o_ptr->to_d = randint1(5) + (HIT_POINT)m_bonus(12, level);
3474 o_ptr->to_h = randint1(5) + (HIT_PROB)m_bonus(12, level);
3480 o_ptr->ident |= (IDENT_BROKEN);
3483 o_ptr->curse_flags |= TRC_CURSED;
3485 /* Reverse bonuses */
3486 o_ptr->to_h = 0 - o_ptr->to_h;
3487 o_ptr->to_d = 0 - o_ptr->to_d;
3493 case SV_RING_MUSCLE:
3495 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(3, level);
3496 if (one_in_(4)) o_ptr->pval++;
3502 o_ptr->ident |= (IDENT_BROKEN);
3505 o_ptr->curse_flags |= TRC_CURSED;
3507 /* Reverse bonuses */
3508 o_ptr->pval = 0 - o_ptr->pval;
3513 case SV_RING_AGGRAVATION:
3516 o_ptr->ident |= (IDENT_BROKEN);
3519 o_ptr->curse_flags |= TRC_CURSED;
3521 if (power > 0) power = 0 - power;
3525 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3526 || (power > 2)) /* power > 2 is debug only */
3528 o_ptr->pval = MIN(o_ptr->pval, 4);
3529 /* Randart amulet */
3530 create_artifact(o_ptr, FALSE);
3532 else if ((power == 2) && one_in_(2))
3534 while(!o_ptr->name2)
3536 int tmp = m_bonus(10, level);
3537 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3538 switch(randint1(28))
3541 o_ptr->name2 = EGO_RING_THROW;
3544 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3545 o_ptr->name2 = EGO_RING_REGEN;
3548 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3549 o_ptr->name2 = EGO_RING_LITE;
3552 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3553 o_ptr->name2 = EGO_RING_TELEPORT;
3556 if (o_ptr->to_h) break;
3557 o_ptr->name2 = EGO_RING_TO_H;
3560 if (o_ptr->to_d) break;
3561 o_ptr->name2 = EGO_RING_TO_D;
3564 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3565 o_ptr->name2 = EGO_RING_SLAY;
3568 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3569 o_ptr->name2 = EGO_RING_WIZARD;
3572 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3573 o_ptr->name2 = EGO_RING_HERO;
3576 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3577 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3578 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3579 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3582 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3583 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;
3584 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3585 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3586 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3589 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3590 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;
3591 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3592 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3593 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3596 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3597 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;
3598 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3599 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3602 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3603 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;
3604 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3605 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3607 case 21: case 22: case 23: case 24: case 25: case 26:
3608 switch (o_ptr->sval)
3611 if (!one_in_(3)) break;
3612 o_ptr->name2 = EGO_RING_D_SPEED;
3614 case SV_RING_DAMAGE:
3615 case SV_RING_ACCURACY:
3616 case SV_RING_SLAYING:
3617 if (one_in_(2)) break;
3618 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3621 o_ptr->name2 = EGO_RING_BERSERKER;
3622 o_ptr->to_h -= 2+randint1(4);
3623 o_ptr->to_d += 2+randint1(4);
3626 case SV_RING_PROTECTION:
3627 o_ptr->name2 = EGO_RING_SUPER_AC;
3628 o_ptr->to_a += 7 + m_bonus(5, level);
3630 case SV_RING_RES_FEAR:
3631 o_ptr->name2 = EGO_RING_HERO;
3634 if (one_in_(2)) break;
3635 o_ptr->name2 = EGO_RING_HUNTER;
3637 case SV_RING_SEARCHING:
3638 o_ptr->name2 = EGO_RING_STEALTH;
3640 case SV_RING_TELEPORTATION:
3641 o_ptr->name2 = EGO_RING_TELE_AWAY;
3643 case SV_RING_RES_BLINDNESS:
3645 o_ptr->name2 = EGO_RING_RES_LITE;
3647 o_ptr->name2 = EGO_RING_RES_DARK;
3649 case SV_RING_LORDLY:
3650 if (!one_in_(20)) break;
3651 one_lordly_high_resistance(o_ptr);
3652 one_lordly_high_resistance(o_ptr);
3653 o_ptr->name2 = EGO_RING_TRUE;
3655 case SV_RING_SUSTAIN:
3656 if (!one_in_(4)) break;
3657 o_ptr->name2 = EGO_RING_RES_TIME;
3659 case SV_RING_FLAMES:
3660 if (!one_in_(2)) break;
3661 o_ptr->name2 = EGO_RING_DRAGON_F;
3664 if (!one_in_(2)) break;
3665 o_ptr->name2 = EGO_RING_DRAGON_C;
3667 case SV_RING_WARNING:
3668 if (!one_in_(2)) break;
3669 o_ptr->name2 = EGO_RING_M_DETECT;
3678 o_ptr->curse_flags = 0L;
3680 else if ((power == -2) && one_in_(2))
3682 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3683 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3684 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3685 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3686 o_ptr->art_flags[0] = 0;
3687 o_ptr->art_flags[1] = 0;
3688 while(!o_ptr->name2)
3690 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3694 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3695 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3698 o_ptr->name2 = EGO_RING_NO_MELEE;
3701 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3702 o_ptr->name2 = EGO_RING_AGGRAVATE;
3705 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3706 o_ptr->name2 = EGO_RING_TY_CURSE;
3709 o_ptr->name2 = EGO_RING_ALBINO;
3714 o_ptr->ident |= (IDENT_BROKEN);
3717 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3725 switch (o_ptr->sval)
3727 /* Amulet of wisdom/charisma */
3728 case SV_AMULET_INTELLIGENCE:
3729 case SV_AMULET_WISDOM:
3730 case SV_AMULET_CHARISMA:
3732 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3738 o_ptr->ident |= (IDENT_BROKEN);
3741 o_ptr->curse_flags |= (TRC_CURSED);
3743 /* Reverse bonuses */
3744 o_ptr->pval = 0 - o_ptr->pval;
3750 /* Amulet of brilliance */
3751 case SV_AMULET_BRILLIANCE:
3753 o_ptr->pval = 1 + m_bonus(3, level);
3754 if (one_in_(4)) o_ptr->pval++;
3760 o_ptr->ident |= (IDENT_BROKEN);
3763 o_ptr->curse_flags |= (TRC_CURSED);
3765 /* Reverse bonuses */
3766 o_ptr->pval = 0 - o_ptr->pval;
3772 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3776 o_ptr->curse_flags |= (TRC_CURSED);
3781 case SV_AMULET_RESISTANCE:
3783 if (one_in_(5)) one_high_resistance(o_ptr);
3784 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3788 /* Amulet of searching */
3789 case SV_AMULET_SEARCHING:
3791 o_ptr->pval = randint1(2) + (PARAMETER_VALUE)m_bonus(4, level);
3797 o_ptr->ident |= (IDENT_BROKEN);
3800 o_ptr->curse_flags |= (TRC_CURSED);
3802 /* Reverse bonuses */
3803 o_ptr->pval = 0 - (o_ptr->pval);
3809 /* Amulet of the Magi -- never cursed */
3810 case SV_AMULET_THE_MAGI:
3812 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3813 o_ptr->to_a = randint1(5) + (ARMOUR_CLASS)m_bonus(5, level);
3815 /* gain one low ESP */
3816 add_esp_weak(o_ptr, FALSE);
3821 /* Amulet of Doom -- always cursed */
3822 case SV_AMULET_DOOM:
3825 o_ptr->ident |= (IDENT_BROKEN);
3828 o_ptr->curse_flags |= (TRC_CURSED);
3831 o_ptr->pval = 0 - (randint1(5) + (PARAMETER_VALUE)m_bonus(5, level));
3832 o_ptr->to_a = 0 - (randint1(5) + (ARMOUR_CLASS)m_bonus(5, level));
3833 if (power > 0) power = 0 - power;
3838 case SV_AMULET_MAGIC_MASTERY:
3840 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(4, level);
3846 o_ptr->ident |= (IDENT_BROKEN);
3849 o_ptr->curse_flags |= (TRC_CURSED);
3851 /* Reverse bonuses */
3852 o_ptr->pval = 0 - o_ptr->pval;
3858 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3859 || (power > 2)) /* power > 2 is debug only */
3861 o_ptr->pval = MIN(o_ptr->pval, 4);
3862 /* Randart amulet */
3863 create_artifact(o_ptr, FALSE);
3865 else if ((power == 2) && one_in_(2))
3867 while(!o_ptr->name2)
3869 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3870 switch(randint1(21))
3873 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3874 o_ptr->name2 = EGO_AMU_SLOW_D;
3877 if (o_ptr->pval) break;
3878 o_ptr->name2 = EGO_AMU_INFRA;
3881 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3882 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3885 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3886 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3889 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3890 o_ptr->name2 = EGO_AMU_LEVITATION;
3892 case 10: case 11: case 21:
3893 o_ptr->name2 = EGO_AMU_AC;
3896 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3897 if (m_bonus(10, level) > 8)
3898 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3900 o_ptr->name2 = EGO_AMU_RES_FIRE;
3903 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3904 if (m_bonus(10, level) > 8)
3905 o_ptr->name2 = EGO_AMU_RES_COLD_;
3907 o_ptr->name2 = EGO_AMU_RES_COLD;
3910 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3911 if (m_bonus(10, level) > 8)
3912 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3914 o_ptr->name2 = EGO_AMU_RES_ELEC;
3917 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3918 if (m_bonus(10, level) > 8)
3919 o_ptr->name2 = EGO_AMU_RES_ACID_;
3921 o_ptr->name2 = EGO_AMU_RES_ACID;
3923 case 16: case 17: case 18: case 19: case 20:
3924 switch (o_ptr->sval)
3926 case SV_AMULET_TELEPORT:
3927 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3928 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3929 else o_ptr->name2 = EGO_AMU_TELEPORT;
3931 case SV_AMULET_RESIST_ACID:
3932 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3934 case SV_AMULET_SEARCHING:
3935 o_ptr->name2 = EGO_AMU_STEALTH;
3937 case SV_AMULET_BRILLIANCE:
3938 if (!one_in_(3)) break;
3939 o_ptr->name2 = EGO_AMU_IDENT;
3941 case SV_AMULET_CHARISMA:
3942 if (!one_in_(3)) break;
3943 o_ptr->name2 = EGO_AMU_CHARM;
3945 case SV_AMULET_THE_MAGI:
3946 if (one_in_(2)) break;
3947 o_ptr->name2 = EGO_AMU_GREAT;
3949 case SV_AMULET_RESISTANCE:
3950 if (!one_in_(5)) break;
3951 o_ptr->name2 = EGO_AMU_DEFENDER;
3953 case SV_AMULET_TELEPATHY:
3954 if (!one_in_(3)) break;
3955 o_ptr->name2 = EGO_AMU_DETECTION;
3961 o_ptr->curse_flags = 0L;
3963 else if ((power == -2) && one_in_(2))
3965 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3966 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3967 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3968 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3969 o_ptr->art_flags[0] = 0;
3970 o_ptr->art_flags[1] = 0;
3971 while(!o_ptr->name2)
3973 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3977 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3978 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3981 o_ptr->name2 = EGO_AMU_FOOL;
3984 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3985 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3988 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3989 o_ptr->name2 = EGO_AMU_TY_CURSE;
3992 o_ptr->name2 = EGO_AMU_NAIVETY;
3997 o_ptr->ident |= (IDENT_BROKEN);
4000 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
4008 * @brief モンスターが人形のベースにできるかを返す
4009 * @param r_idx チェックしたいモンスター種族のID
4010 * @return 人形にできるならTRUEを返す
4012 static bool item_monster_okay(MONRACE_IDX r_idx)
4014 monster_race *r_ptr = &r_info[r_idx];
4017 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
4018 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
4019 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
4020 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
4021 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
4022 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
4030 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
4031 * Apply magic to an item known to be "boring"
4032 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4033 * @param level 生成基準階
4034 * @param power 生成ランク
4037 * Hack -- note the special code for various items
4039 static void a_m_aux_4(object_type *o_ptr, DEPTH level, int power)
4041 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4046 /* Apply magic (good or bad) according to type */
4047 switch (o_ptr->tval)
4056 o_ptr->ident |= (IDENT_BROKEN);
4059 o_ptr->curse_flags |= (TRC_CURSED);
4066 o_ptr->xtra4 = o_ptr->pval;
4072 /* Hack -- Torches -- random fuel */
4073 if (o_ptr->sval == SV_LITE_TORCH)
4075 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4079 /* Hack -- Lanterns -- random fuel */
4080 if (o_ptr->sval == SV_LITE_LANTERN)
4082 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4086 if (power > 2) /* power > 2 is debug only */
4088 create_artifact(o_ptr, FALSE);
4090 else if ((power == 2) || ((power == 1) && one_in_(3)))
4092 while (!o_ptr->name2)
4096 bool okay_flag = TRUE;
4098 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4100 switch (o_ptr->name2)
4103 if (o_ptr->sval == SV_LITE_FEANOR)
4111 else if (power == -2)
4113 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4115 switch (o_ptr->name2)
4117 case EGO_LITE_DARKNESS:
4120 if (o_ptr->sval == SV_LITE_TORCH)
4122 add_flag(o_ptr->art_flags, TR_LITE_M1);
4124 else if (o_ptr->sval == SV_LITE_LANTERN)
4126 add_flag(o_ptr->art_flags, TR_LITE_M2);
4128 else if (o_ptr->sval == SV_LITE_FEANOR)
4130 add_flag(o_ptr->art_flags, TR_LITE_M3);
4142 /* The wand or staff gets a number of initial charges equal
4143 * to between 1/2 (+1) and the full object kind's pval. -LM-
4145 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4151 /* Transfer the pval. -LM- */
4152 o_ptr->pval = k_ptr->pval;
4159 object_aware(o_ptr);
4160 object_known(o_ptr);
4166 PARAMETER_VALUE i = 1;
4169 monster_race *r_ptr;
4171 /* Pick a random non-unique monster race */
4174 i = randint1(max_r_idx - 1);
4176 if (!item_monster_okay(i)) continue;
4177 if (i == MON_TSUCHINOKO) continue;
4181 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4183 /* Ignore dead monsters */
4184 if (!r_ptr->rarity) continue;
4186 /* Ignore uncommon monsters */
4187 if (r_ptr->rarity > 100) continue;
4189 /* Prefer less out-of-depth monsters */
4190 if (randint0(check)) continue;
4197 /* Some figurines are cursed */
4198 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4205 PARAMETER_VALUE i = 1;
4210 monster_race *r_ptr;
4212 if (o_ptr->sval == SV_SKELETON)
4214 match = RF9_DROP_SKELETON;
4216 else if (o_ptr->sval == SV_CORPSE)
4218 match = RF9_DROP_CORPSE;
4221 /* Hack -- Remove the monster restriction */
4222 get_mon_num_prep(item_monster_okay, NULL);
4224 /* Pick a random non-unique monster race */
4227 i = get_mon_num(dun_level);
4231 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4233 /* Ignore dead monsters */
4234 if (!r_ptr->rarity) continue;
4236 /* Ignore corpseless monsters */
4237 if (!(r_ptr->flags9 & match)) continue;
4239 /* Prefer less out-of-depth monsters */
4240 if (randint0(check)) continue;
4248 object_aware(o_ptr);
4249 object_known(o_ptr);
4255 PARAMETER_VALUE i = 1;
4257 monster_race *r_ptr;
4259 /* Pick a random monster race */
4262 i = randint1(max_r_idx - 1);
4266 /* Ignore dead monsters */
4267 if (!r_ptr->rarity) continue;
4276 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4278 object_aware(o_ptr);
4279 object_known(o_ptr);
4286 DEPTH obj_level = k_info[o_ptr->k_idx].level;
4288 /* Hack -- skip ruined chests */
4289 if (obj_level <= 0) break;
4291 /* Hack -- pick a "difficulty" */
4292 o_ptr->pval = randint1(obj_level);
4293 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4295 o_ptr->xtra3 = dun_level + 5;
4297 /* Never exceed "difficulty" of 55 to 59 */
4298 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4306 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4307 * Complete the "creation" of an object by applying "magic" to the item
4308 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4310 * @param mode 生成オプション
4313 * This includes not only rolling for random bonuses, but also putting the\n
4314 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4315 * staffs, giving fuel to lites, and placing traps on chests.\n
4317 * In particular, note that "Instant Artifacts", if "created" by an external\n
4318 * routine, must pass through this function to complete the actual creation.\n
4320 * The base "chance" of the item being "good" increases with the "level"\n
4321 * parameter, which is usually derived from the dungeon level, being equal\n
4322 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4323 * the object is guaranteed to be "good". If an object is "good", then\n
4324 * the chance that the object will be "great" (ego-item or artifact), also\n
4325 * increases with the "level", being equal to half the level, plus 5, up to\n
4326 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4327 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4329 * If the object is not "good", there is a chance it will be "cursed", and\n
4330 * if it is "cursed", there is a chance it will be "broken". These chances\n
4331 * are related to the "good" / "great" chances above.\n
4333 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4334 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4336 * If "okay" is true, and the object is going to be "great", then there is\n
4337 * a chance that an artifact will be created. This is true even if both the\n
4338 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4339 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4341 void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
4343 int i, rolls, f1, f2, power;
4345 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4347 /* Maximum "level" for various things */
4348 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4350 /* Base chance of being "good" */
4353 /* Maximal chance of being "good" */
4354 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4356 /* Base chance of being "great" */
4359 /* Maximal chance of being "great" */
4360 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4361 f2 = d_info[dungeon_type].obj_great;
4363 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4368 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4377 /* Roll for "good" */
4378 if ((mode & AM_GOOD) || magik(f1))
4383 /* Roll for "great" */
4384 if ((mode & AM_GREAT) || magik(f2))
4388 /* Roll for "special" */
4389 if (mode & AM_SPECIAL) power = 3;
4393 /* Roll for "cursed" */
4396 /* Assume "cursed" */
4399 /* Roll for "broken" */
4400 if (magik(f2)) power = -2;
4404 if (mode & AM_CURSED)
4406 /* Assume 'cursed' */
4411 /* Everything else gets more badly cursed */
4418 /* Assume no rolls */
4421 /* Get one roll if excellent */
4422 if (power >= 2) rolls = 1;
4424 /* Hack -- Get four rolls if forced great or special */
4425 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4427 /* Hack -- Get no rolls if not allowed */
4428 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4430 /* Roll for artifacts if allowed */
4431 for (i = 0; i < rolls; i++)
4433 /* Roll for an artifact */
4434 if (make_artifact(o_ptr)) break;
4435 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4437 if (make_artifact(o_ptr)) break;
4442 /* Hack -- analyze artifacts */
4443 if (object_is_fixed_artifact(o_ptr))
4445 artifact_type *a_ptr = &a_info[o_ptr->name1];
4447 /* Hack -- Mark the artifact as "created" */
4450 /* Hack -- Memorize location of artifact in saved floors */
4451 if (character_dungeon)
4452 a_ptr->floor_id = p_ptr->floor_id;
4454 /* Extract the other fields */
4455 o_ptr->pval = a_ptr->pval;
4456 o_ptr->ac = a_ptr->ac;
4457 o_ptr->dd = a_ptr->dd;
4458 o_ptr->ds = a_ptr->ds;
4459 o_ptr->to_a = a_ptr->to_a;
4460 o_ptr->to_h = a_ptr->to_h;
4461 o_ptr->to_d = a_ptr->to_d;
4462 o_ptr->weight = a_ptr->weight;
4463 o_ptr->xtra2 = a_ptr->act_idx;
4465 if (o_ptr->name1 == ART_MILIM)
4467 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4473 /* Hack -- extract the "broken" flag */
4474 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4476 /* Hack -- extract the "cursed" flag */
4477 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4478 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4479 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4480 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4481 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4482 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4490 switch (o_ptr->tval)
4499 if (power) a_m_aux_1(o_ptr, lev, power);
4505 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4511 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4525 /* Elven Cloak and Black Clothes ... */
4526 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4527 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4528 o_ptr->pval = randint1(4);
4532 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4533 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4534 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4535 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4536 a_m_aux_2(o_ptr, lev, power);
4538 if (power) a_m_aux_2(o_ptr, lev, power);
4546 if (!power && (randint0(100) < 50)) power = -1;
4547 a_m_aux_3(o_ptr, lev, power);
4553 a_m_aux_4(o_ptr, lev, power);
4558 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4559 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4560 (p_ptr->pseikaku == SEIKAKU_SEXY))
4563 add_flag(o_ptr->art_flags, TR_STR);
4564 add_flag(o_ptr->art_flags, TR_INT);
4565 add_flag(o_ptr->art_flags, TR_WIS);
4566 add_flag(o_ptr->art_flags, TR_DEX);
4567 add_flag(o_ptr->art_flags, TR_CON);
4568 add_flag(o_ptr->art_flags, TR_CHR);
4571 /* Hack -- analyze ego-items */
4572 if (object_is_ego(o_ptr))
4574 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4576 /* Hack -- acquire "broken" flag */
4577 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4579 /* Hack -- acquire "cursed" flag */
4580 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4581 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4582 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4583 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4584 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4585 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4587 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4588 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4589 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4590 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4591 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4592 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4593 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4594 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4600 while (one_in_(o_ptr->dd));
4602 if (o_ptr->dd > 9) o_ptr->dd = 9;
4605 /* Hack -- apply activatin index if needed */
4606 if (e_ptr->act_idx) o_ptr->xtra2 = (XTRA8)e_ptr->act_idx;
4608 /* Hack -- apply extra penalties if needed */
4609 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4611 /* Hack -- obtain bonuses */
4612 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4613 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4614 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4616 /* Hack -- obtain pval */
4617 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4620 /* Hack -- apply extra bonuses if needed */
4623 /* Hack -- obtain bonuses */
4624 if (e_ptr->max_to_h)
4626 if (e_ptr->max_to_h > 127)
4627 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4628 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4630 if (e_ptr->max_to_d)
4632 if (e_ptr->max_to_d > 127)
4633 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4634 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4636 if (e_ptr->max_to_a)
4638 if (e_ptr->max_to_a > 127)
4639 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4640 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4643 /* Accuracy ego must have high to_h */
4644 if(o_ptr->name2 == EGO_ACCURACY)
4646 while(o_ptr->to_h < o_ptr->to_d + 10)
4651 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4654 /* Accuracy ego must have high to_h */
4655 if(o_ptr->name2 == EGO_VELOCITY)
4657 while(o_ptr->to_d < o_ptr->to_h + 10)
4662 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4665 /* Protection ego must have high to_a */
4666 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4668 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4671 /* Hack -- obtain pval */
4672 if (e_ptr->max_pval)
4674 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4677 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4679 else if (o_ptr->name2 == EGO_DEMON)
4681 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4683 o_ptr->pval += randint1(2);
4687 o_ptr->pval += randint1(e_ptr->max_pval);
4690 else if (o_ptr->name2 == EGO_ATTACKS)
4692 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4693 if (o_ptr->pval > 3) o_ptr->pval = 3;
4694 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4695 o_ptr->pval += randint1(2);
4697 else if (o_ptr->name2 == EGO_BAT)
4699 o_ptr->pval = randint1(e_ptr->max_pval);
4700 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4702 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4704 o_ptr->pval = randint1(e_ptr->max_pval);
4708 o_ptr->pval += randint1(e_ptr->max_pval);
4713 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4715 o_ptr->pval = randint1(o_ptr->pval);
4717 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4725 /* Examine real objects */
4728 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4730 /* Hack -- acquire "broken" flag */
4731 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4733 /* Hack -- acquire "cursed" flag */
4734 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4735 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4736 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4737 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4738 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4739 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4747 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4748 * Hack -- determine if a template is "good"
4749 * @param k_idx 判定したいベースアイテムのID
4750 * @return ベースアイテムが上質ならばTRUEを返す。
4752 static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4754 object_kind *k_ptr = &k_info[k_idx];
4756 /* Analyze the item type */
4757 switch (k_ptr->tval)
4759 /* Armor -- Good unless damaged */
4770 if (k_ptr->to_a < 0) return (FALSE);
4774 /* Weapons -- Good unless damaged */
4781 if (k_ptr->to_h < 0) return (FALSE);
4782 if (k_ptr->to_d < 0) return (FALSE);
4786 /* Ammo -- Arrows/Bolts are good */
4793 /* Books -- High level books are good (except Arcane books) */
4795 case TV_SORCERY_BOOK:
4796 case TV_NATURE_BOOK:
4801 case TV_DAEMON_BOOK:
4802 case TV_CRUSADE_BOOK:
4804 case TV_HISSATSU_BOOK:
4807 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4811 /* Rings -- Rings of Speed are good */
4814 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4815 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4819 /* Amulets -- Amulets of the Magi and Resistance are good */
4822 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4823 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4828 /* Assume not good */
4833 * @brief 生成階に応じたベースアイテムの生成を行う。
4834 * Attempt to make an object (normal or good/great)
4835 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4836 * @param mode オプションフラグ
4837 * @return 生成に成功したらTRUEを返す。
4839 * This routine plays nasty games to generate the "special artifacts".\n
4840 * This routine uses "object_level" for the "generation level".\n
4841 * We assume that the given object has been "wiped".\n
4843 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
4849 /* Chance of "special object" */
4850 prob = ((mode & AM_GOOD) ? 10 : 1000);
4852 /* Base level for the object */
4853 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4856 /* Generate a special object, or a normal object */
4857 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4862 if ((mode & AM_GOOD) && !get_obj_num_hook)
4864 /* Activate restriction (if already specified, use that) */
4865 get_obj_num_hook = kind_is_good;
4868 /* Restricted objects - prepare allocation table */
4869 if (get_obj_num_hook) get_obj_num_prep();
4871 /* Pick a random object */
4872 k_idx = get_obj_num(base);
4874 /* Restricted objects */
4875 if (get_obj_num_hook)
4877 /* Clear restriction */
4878 get_obj_num_hook = NULL;
4880 /* Reset allocation table to default */
4884 /* Handle failure */
4885 if (!k_idx) return (FALSE);
4887 /* Prepare the object */
4888 object_prep(j_ptr, k_idx);
4891 /* Apply magic (allow artifacts) */
4892 apply_magic(j_ptr, object_level, mode);
4894 /* Hack -- generate multiple spikes/missiles */
4895 switch (j_ptr->tval)
4903 j_ptr->number = (byte)damroll(6, 7);
4907 if (cheat_peek) object_mention(j_ptr);
4915 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4916 * Attempt to place an object (normal or good/great) at the given location.
4917 * @param y 配置したいフロアのY座標
4918 * @param x 配置したいフロアのX座標
4919 * @param mode オプションフラグ
4920 * @return 生成に成功したらTRUEを返す。
4922 * This routine plays nasty games to generate the "special artifacts".\n
4923 * This routine uses "object_level" for the "generation level".\n
4924 * This routine requires a clean floor grid destination.\n
4926 void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
4931 cave_type *c_ptr = &cave[y][x];
4937 /* Paranoia -- check bounds */
4938 if (!in_bounds(y, x)) return;
4940 /* Require floor space */
4941 if (!cave_drop_bold(y, x)) return;
4943 /* Avoid stacking on other objects */
4944 if (c_ptr->o_idx) return;
4947 /* Get local object */
4950 /* Wipe the object */
4953 /* Make an object (if possible) */
4954 if (!make_object(q_ptr, mode)) return;
4957 /* Make an object */
4965 /* Acquire object */
4966 o_ptr = &o_list[o_idx];
4968 /* Structure Copy */
4969 object_copy(o_ptr, q_ptr);
4976 o_ptr->next_o_idx = c_ptr->o_idx;
4978 /* Place the object */
4979 c_ptr->o_idx = o_idx;
4989 /* Hack -- Preserve artifacts */
4990 if (object_is_fixed_artifact(q_ptr))
4992 a_info[q_ptr->name1].cur_num = 0;
4999 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
5000 * Make a treasure object
5001 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
5002 * @return 生成に成功したらTRUEを返す。
5004 * The location must be a legal, clean, floor grid.
5006 bool make_gold(object_type *j_ptr)
5011 /* Hack -- Pick a Treasure variety */
5012 i = ((randint1(object_level + 2) + 2) / 2) - 1;
5014 /* Apply "extra" magic */
5015 if (one_in_(GREAT_OBJ))
5017 i += randint1(object_level + 1);
5020 /* Hack -- Creeping Coins only generate "themselves" */
5021 if (coin_type) i = coin_type;
5023 /* Do not create "illegal" Treasure Types */
5024 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
5026 /* Prepare a gold object */
5027 object_prep(j_ptr, OBJ_GOLD_LIST + i);
5029 /* Hack -- Base coin cost */
5030 base = k_info[OBJ_GOLD_LIST + i].cost;
5032 /* Determine how much the treasure is "worth" */
5033 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5041 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
5042 * Places a treasure (Gold or Gems) at given location
5043 * @param y 配置したいフロアのY座標
5044 * @param x 配置したいフロアのX座標
5045 * @return 生成に成功したらTRUEを返す。
5047 * The location must be a legal, clean, floor grid.
5049 void place_gold(POSITION y, POSITION x)
5054 cave_type *c_ptr = &cave[y][x];
5060 /* Paranoia -- check bounds */
5061 if (!in_bounds(y, x)) return;
5063 /* Require floor space */
5064 if (!cave_drop_bold(y, x)) return;
5066 /* Avoid stacking on other objects */
5067 if (c_ptr->o_idx) return;
5070 /* Get local object */
5073 /* Wipe the object */
5076 /* Make some gold */
5077 if (!make_gold(q_ptr)) return;
5079 /* Make an object */
5087 /* Acquire object */
5088 o_ptr = &o_list[o_idx];
5090 /* Copy the object */
5091 object_copy(o_ptr, q_ptr);
5098 o_ptr->next_o_idx = c_ptr->o_idx;
5100 /* Place the object */
5101 c_ptr->o_idx = o_idx;
5113 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5114 * Let an object fall to the ground at or near a location.
5115 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5116 * @param chance ドロップの成功率(%)
5117 * @param y 配置したいフロアのY座標
5118 * @param x 配置したいフロアのX座標
5119 * @return 生成に成功したらオブジェクトのIDを返す。
5121 * The initial location is assumed to be "in_bounds()".\n
5123 * This function takes a parameter "chance". This is the percentage\n
5124 * chance that the item will "disappear" instead of drop. If the object\n
5125 * has been thrown, then this is the chance of disappearance on contact.\n
5127 * Hack -- this function uses "chance" to determine if it should produce\n
5128 * some form of "description" of the drop event (under the player).\n
5130 * We check several locations to see if we can find a location at which\n
5131 * the object can combine, stack, or be placed. Artifacts will try very\n
5132 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5134 OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION x)
5141 POSITION ty, tx = 0;
5143 OBJECT_IDX o_idx = 0;
5144 OBJECT_IDX this_o_idx, next_o_idx = 0;
5148 char o_name[MAX_NLEN];
5154 /* Extract plural */
5155 bool plural = (j_ptr->number != 1);
5158 /* Describe object */
5159 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5162 /* Handle normal "breakage" */
5163 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5167 msg_format("%sは消えた。", o_name);
5169 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5172 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5189 /* Scan local grids */
5190 for (dy = -3; dy <= 3; dy++)
5192 /* Scan local grids */
5193 for (dx = -3; dx <= 3; dx++)
5197 /* Calculate actual distance */
5198 d = (dy * dy) + (dx * dx);
5200 /* Ignore distant grids */
5201 if (d > 10) continue;
5207 /* Skip illegal grids */
5208 if (!in_bounds(ty, tx)) continue;
5210 /* Require line of projection */
5211 if (!projectable(y, x, ty, tx)) continue;
5214 c_ptr = &cave[ty][tx];
5216 /* Require floor space */
5217 if (!cave_drop_bold(ty, tx)) continue;
5222 /* Scan objects in that grid */
5223 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5227 /* Acquire object */
5228 o_ptr = &o_list[this_o_idx];
5230 /* Acquire next object */
5231 next_o_idx = o_ptr->next_o_idx;
5233 /* Check for possible combination */
5234 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5240 /* Add new object */
5244 if (k > 99) continue;
5246 /* Calculate score */
5247 s = 1000 - (d + k * 5);
5249 /* Skip bad values */
5250 if (s < bs) continue;
5252 /* New best value */
5255 /* Apply the randomizer to equivalent values */
5256 if ((++bn >= 2) && !one_in_(bn)) continue;
5271 /* Handle lack of space */
5272 if (!flag && !object_is_artifact(j_ptr))
5276 msg_format("%sは消えた。", o_name);
5278 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5283 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5291 for (i = 0; !flag && (i < 1000); i++)
5294 ty = rand_spread(by, 1);
5295 tx = rand_spread(bx, 1);
5297 /* Verify location */
5298 if (!in_bounds(ty, tx)) continue;
5300 /* Bounce to that location */
5304 /* Require floor space */
5305 if (!cave_drop_bold(by, bx)) continue;
5314 int candidates = 0, pick;
5316 for (ty = 1; ty < cur_hgt - 1; ty++)
5318 for (tx = 1; tx < cur_wid - 1; tx++)
5320 /* A valid space found */
5321 if (cave_drop_bold(ty, tx)) candidates++;
5325 /* No valid place! */
5330 msg_format("%sは消えた。", o_name);
5332 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5336 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5338 /* Mega-Hack -- preserve artifacts */
5341 /* Hack -- Preserve unknown artifacts */
5342 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5344 /* Mega-Hack -- Preserve the artifact */
5345 a_info[j_ptr->name1].cur_num = 0;
5353 /* Choose a random one */
5354 pick = randint1(candidates);
5356 for (ty = 1; ty < cur_hgt - 1; ty++)
5358 for (tx = 1; tx < cur_wid - 1; tx++)
5360 if (cave_drop_bold(ty, tx))
5364 /* Is this a picked one? */
5378 c_ptr = &cave[by][bx];
5380 /* Scan objects in that grid for combination */
5381 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5385 /* Acquire object */
5386 o_ptr = &o_list[this_o_idx];
5388 /* Acquire next object */
5389 next_o_idx = o_ptr->next_o_idx;
5391 /* Check for combination */
5392 if (object_similar(o_ptr, j_ptr))
5394 /* Combine the items */
5395 object_absorb(o_ptr, j_ptr);
5405 /* Get new object */
5406 if (!done) o_idx = o_pop();
5409 if (!done && !o_idx)
5413 msg_format("%sは消えた。", o_name);
5415 msg_format("The %s disappear%s.",
5416 o_name, (plural ? "" : "s"));
5421 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5423 /* Hack -- Preserve artifacts */
5424 if (object_is_fixed_artifact(j_ptr))
5426 a_info[j_ptr->name1].cur_num = 0;
5436 /* Structure copy */
5437 object_copy(&o_list[o_idx], j_ptr);
5439 /* Access new object */
5440 j_ptr = &o_list[o_idx];
5447 j_ptr->held_m_idx = 0;
5450 j_ptr->next_o_idx = c_ptr->o_idx;
5452 /* Place the object */
5453 c_ptr->o_idx = o_idx;
5467 /* Mega-Hack -- no message if "dropped" by player */
5468 /* Message when an object falls under the player */
5469 if (chance && player_bold(by, bx))
5471 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5483 * Scatter some "great" objects near the player
5484 * @param y1 配置したいフロアのY座標
5485 * @param x1 配置したいフロアのX座標
5486 * @param num 獲得の処理回数
5487 * @param great TRUEならば必ず高級品以上を落とす
5488 * @param special TRUEならば必ず特別品を落とす
5489 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5492 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
5495 object_type object_type_body;
5496 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5501 /* Get local object */
5502 i_ptr = &object_type_body;
5504 /* Wipe the object */
5507 /* Make a good (or great) object (if possible) */
5508 if (!make_object(i_ptr, mode)) continue;
5512 object_aware(i_ptr);
5513 object_known(i_ptr);
5516 /* Drop the object */
5517 (void)drop_near(i_ptr, -1, y1, x1);
5522 * Scatter some "amusing" objects near the player
5525 #define AMS_NOTHING 0x00 /* No restriction */
5526 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5527 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5528 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5529 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5533 OBJECT_TYPE_VALUE tval;
5534 OBJECT_SUBTYPE_VALUE sval;
5539 amuse_type amuse_info[] =
5541 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5542 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5543 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5544 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5545 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5546 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5547 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5548 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5549 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5550 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5551 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5552 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5553 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5560 * @param y1 配置したいフロアのY座標
5561 * @param x1 配置したいフロアのX座標
5562 * @param num 誰得の処理回数
5563 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5566 void amusement(POSITION y1, POSITION x1, int num, bool known)
5569 object_type object_type_body;
5572 for (n = 0; amuse_info[n].tval != 0; n++)
5574 t += amuse_info[n].prob;
5581 IDX k_idx, a_idx = 0;
5582 int r = randint0(t);
5583 bool insta_art, fixed_art;
5587 r -= amuse_info[i].prob;
5591 /* Get local object */
5592 i_ptr = &object_type_body;
5594 /* Wipe the object */
5597 /* Wipe the object */
5598 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5600 /* Paranoia - reroll if nothing */
5601 if (!k_idx) continue;
5603 /* Search an artifact index if need */
5604 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5605 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5607 if (insta_art || fixed_art)
5609 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5611 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5612 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5613 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5614 if (a_info[a_idx].cur_num > 0) continue;
5618 if (a_idx >= max_a_idx) continue;
5621 /* Make an object (if possible) */
5622 object_prep(i_ptr, k_idx);
5623 if (a_idx) i_ptr->name1 = a_idx;
5624 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5626 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5628 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5631 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5632 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5636 object_aware(i_ptr);
5637 object_known(i_ptr);
5640 /* Paranoia - reroll if nothing */
5641 if (!(i_ptr->k_idx)) continue;
5643 /* Drop the object */
5644 (void)drop_near(i_ptr, -1, y1, x1);
5652 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5653 * Describe the charges on an item in the inventory.
5654 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5657 void inven_item_charges(INVENTORY_IDX item)
5659 object_type *o_ptr = &inventory[item];
5661 /* Require staff/wand */
5662 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5664 /* Require known item */
5665 if (!object_is_known(o_ptr)) return;
5668 if (o_ptr->pval <= 0)
5670 msg_print("もう魔力が残っていない。");
5674 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5677 /* Multiple charges */
5678 if (o_ptr->pval != 1)
5680 /* Print a message */
5681 msg_format("You have %d charges remaining.", o_ptr->pval);
5687 /* Print a message */
5688 msg_format("You have %d charge remaining.", o_ptr->pval);
5695 * @brief アイテムの残り所持数メッセージを表示する /
5696 * Describe an item in the inventory.
5697 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5700 void inven_item_describe(INVENTORY_IDX item)
5702 object_type *o_ptr = &inventory[item];
5703 char o_name[MAX_NLEN];
5705 /* Get a description */
5706 object_desc(o_name, o_ptr, 0);
5708 /* Print a message */
5710 /* "no more" の場合はこちらで表示する */
5711 if (o_ptr->number <= 0)
5713 /*FIRST*//*ここはもう通らないかも */
5714 msg_format("もう%sを持っていない。", o_name);
5718 /* アイテム名を英日切り替え機能対応 */
5719 msg_format("まだ %sを持っている。", o_name);
5722 msg_format("You have %s.", o_name);
5728 * @brief アイテムの残り所持数メッセージを表示する /
5729 * Increase the "number" of an item in the inventory
5730 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5734 void inven_item_increase(INVENTORY_IDX item, int num)
5736 object_type *o_ptr = &inventory[item];
5739 num += o_ptr->number;
5742 if (num > 255) num = 255;
5743 else if (num < 0) num = 0;
5746 num -= (ITEM_NUMBER)o_ptr->number;
5748 /* Change the number and weight */
5751 /* Add the number */
5752 o_ptr->number += num;
5754 /* Add the weight */
5755 p_ptr->total_weight += (num * o_ptr->weight);
5757 /* Recalculate bonuses */
5758 p_ptr->update |= (PU_BONUS);
5760 /* Recalculate mana XXX */
5761 p_ptr->update |= (PU_MANA);
5763 /* Combine the pack */
5764 p_ptr->notice |= (PN_COMBINE);
5767 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5769 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5770 if (!o_ptr->number && p_ptr->ele_attack)
5772 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5774 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5776 /* Clear all temporary elemental brands */
5777 set_ele_attack(0, 0);
5785 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5786 * Erase an inventory slot if it has no more items
5787 * @param item 消去したいプレイヤーのアイテム所持スロット
5790 void inven_item_optimize(INVENTORY_IDX item)
5792 object_type *o_ptr = &inventory[item];
5794 /* Only optimize real items */
5795 if (!o_ptr->k_idx) return;
5797 /* Only optimize empty items */
5798 if (o_ptr->number) return;
5800 /* The item is in the pack */
5801 if (item < INVEN_RARM)
5808 /* Slide everything down */
5809 for (i = item; i < INVEN_PACK; i++)
5811 /* Structure copy */
5812 inventory[i] = inventory[i+1];
5815 /* Erase the "final" slot */
5816 object_wipe(&inventory[i]);
5819 p_ptr->window |= (PW_INVEN);
5822 /* The item is being wielded */
5828 /* Erase the empty slot */
5829 object_wipe(&inventory[item]);
5831 /* Recalculate bonuses */
5832 p_ptr->update |= (PU_BONUS);
5834 /* Recalculate torch */
5835 p_ptr->update |= (PU_TORCH);
5837 /* Recalculate mana XXX */
5838 p_ptr->update |= (PU_MANA);
5841 p_ptr->window |= (PW_EQUIP);
5845 p_ptr->window |= (PW_SPELL);
5849 * @brief 床上の魔道具の残り残量メッセージを表示する /
5850 * Describe the charges on an item on the floor.
5851 * @param item メッセージの対象にしたいアイテム所持スロット
5854 void floor_item_charges(INVENTORY_IDX item)
5856 object_type *o_ptr = &o_list[item];
5858 /* Require staff/wand */
5859 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5861 /* Require known item */
5862 if (!object_is_known(o_ptr)) return;
5865 if (o_ptr->pval <= 0)
5867 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5871 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5874 /* Multiple charges */
5875 if (o_ptr->pval != 1)
5877 /* Print a message */
5878 msg_format("There are %d charges remaining.", o_ptr->pval);
5884 /* Print a message */
5885 msg_format("There is %d charge remaining.", o_ptr->pval);
5892 * @brief 床上のアイテムの残り数メッセージを表示する /
5893 * Describe the charges on an item on the floor.
5894 * @param item メッセージの対象にしたいアイテム所持スロット
5897 void floor_item_describe(INVENTORY_IDX item)
5899 object_type *o_ptr = &o_list[item];
5900 char o_name[MAX_NLEN];
5902 /* Get a description */
5903 object_desc(o_name, o_ptr, 0);
5905 /* Print a message */
5907 /* "no more" の場合はこちらで表示を分ける */
5908 if (o_ptr->number <= 0)
5910 msg_format("床上には、もう%sはない。", o_name);
5914 msg_format("床上には、まだ %sがある。", o_name);
5917 msg_format("You see %s.", o_name);
5924 * @brief 床上のアイテムの数を増やす /
5925 * Increase the "number" of an item on the floor
5926 * @param item 増やしたいアイテムの所持スロット
5927 * @param num 増やしたいアイテムの数
5930 void floor_item_increase(INVENTORY_IDX item, int num)
5932 object_type *o_ptr = &o_list[item];
5935 num += o_ptr->number;
5938 if (num > 255) num = 255;
5939 else if (num < 0) num = 0;
5942 num -= (int)o_ptr->number;
5944 /* Change the number */
5945 o_ptr->number += (ITEM_NUMBER)num;
5950 * @brief 床上の数の無くなったアイテムスロットを消去する /
5951 * Optimize an item on the floor (destroy "empty" items)
5952 * @param item 消去したいアイテムの所持スロット
5955 void floor_item_optimize(INVENTORY_IDX item)
5957 object_type *o_ptr = &o_list[item];
5959 /* Paranoia -- be sure it exists */
5960 if (!o_ptr->k_idx) return;
5962 /* Only optimize empty items */
5963 if (o_ptr->number) return;
5965 /* Delete the object */
5966 delete_object_idx(item);
5971 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
5972 * Check if we have space for an item in the pack without overflow
5973 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
5974 * @return 溢れずに済むならTRUEを返す
5976 bool inven_carry_okay(object_type *o_ptr)
5981 if (inven_cnt < INVEN_PACK) return (TRUE);
5984 for (j = 0; j < INVEN_PACK; j++)
5986 object_type *j_ptr = &inventory[j];
5988 /* Skip non-objects */
5989 if (!j_ptr->k_idx) continue;
5991 /* Check if the two items can be combined */
5992 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6000 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6001 * Check if we have space for an item in the pack without overflow
6002 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6003 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6004 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6005 * @return o_ptrの方が上位ならばTRUEを返す。
6007 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6011 /* Use empty slots */
6012 if (!j_ptr->k_idx) return TRUE;
6014 /* Hack -- readable books always come first */
6015 if ((o_ptr->tval == REALM1_BOOK) &&
6016 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6017 if ((j_ptr->tval == REALM1_BOOK) &&
6018 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6020 if ((o_ptr->tval == REALM2_BOOK) &&
6021 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6022 if ((j_ptr->tval == REALM2_BOOK) &&
6023 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6025 /* Objects sort by decreasing type */
6026 if (o_ptr->tval > j_ptr->tval) return TRUE;
6027 if (o_ptr->tval < j_ptr->tval) return FALSE;
6029 /* Non-aware (flavored) items always come last */
6030 /* Can happen in the home */
6031 if (!object_is_aware(o_ptr)) return FALSE;
6032 if (!object_is_aware(j_ptr)) return TRUE;
6034 /* Objects sort by increasing sval */
6035 if (o_ptr->sval < j_ptr->sval) return TRUE;
6036 if (o_ptr->sval > j_ptr->sval) return FALSE;
6038 /* Unidentified objects always come last */
6039 /* Objects in the home can be unknown */
6040 if (!object_is_known(o_ptr)) return FALSE;
6041 if (!object_is_known(j_ptr)) return TRUE;
6043 /* Fixed artifacts, random artifacts and ego items */
6044 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6045 else if (o_ptr->art_name) o_type = 2;
6046 else if (object_is_ego(o_ptr)) o_type = 1;
6049 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6050 else if (j_ptr->art_name) j_type = 2;
6051 else if (object_is_ego(j_ptr)) j_type = 1;
6054 if (o_type < j_type) return TRUE;
6055 if (o_type > j_type) return FALSE;
6057 switch (o_ptr->tval)
6063 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6064 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6070 /* Objects sort by increasing hit/damage bonuses */
6071 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6072 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6075 /* Hack: otherwise identical rods sort by
6076 increasing recharge time --dsb */
6078 if (o_ptr->pval < j_ptr->pval) return TRUE;
6079 if (o_ptr->pval > j_ptr->pval) return FALSE;
6083 /* Objects sort by decreasing value */
6084 return o_value > object_value(j_ptr);
6089 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6090 * Add an item to the players inventory, and return the slot used.
6091 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6092 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6094 * If the new item can combine with an existing item in the inventory,\n
6095 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6096 * the item will be placed into the "proper" location in the inventory.\n
6098 * This function can be used to "over-fill" the player's pack, but only\n
6099 * once, and such an action must trigger the "overflow" code immediately.\n
6100 * Note that when the pack is being "over-filled", the new item must be\n
6101 * placed into the "overflow" slot, and the "overflow" must take place\n
6102 * before the pack is reordered, but (optionally) after the pack is\n
6103 * combined. This may be tricky. See "dungeon.c" for info.\n
6105 * Note that this code must remove any location/stack information\n
6106 * from the object once it is placed into the inventory.\n
6108 s16b inven_carry(object_type *o_ptr)
6110 INVENTORY_IDX i, j, k;
6111 INVENTORY_IDX n = -1;
6116 /* Check for combining */
6117 for (j = 0; j < INVEN_PACK; j++)
6119 j_ptr = &inventory[j];
6121 /* Skip non-objects */
6122 if (!j_ptr->k_idx) continue;
6124 /* Hack -- track last item */
6127 /* Check if the two items can be combined */
6128 if (object_similar(j_ptr, o_ptr))
6130 /* Combine the items */
6131 object_absorb(j_ptr, o_ptr);
6133 /* Increase the weight */
6134 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6136 /* Recalculate bonuses */
6137 p_ptr->update |= (PU_BONUS);
6140 p_ptr->window |= (PW_INVEN);
6149 if (inven_cnt > INVEN_PACK) return (-1);
6151 /* Find an empty slot */
6152 for (j = 0; j <= INVEN_PACK; j++)
6154 j_ptr = &inventory[j];
6156 /* Use it if found */
6157 if (!j_ptr->k_idx) break;
6164 /* Reorder the pack */
6167 /* Get the "value" of the item */
6168 s32b o_value = object_value(o_ptr);
6170 /* Scan every occupied slot */
6171 for (j = 0; j < INVEN_PACK; j++)
6173 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6180 for (k = n; k >= i; k--)
6182 /* Hack -- Slide the item */
6183 object_copy(&inventory[k+1], &inventory[k]);
6186 /* Wipe the empty slot */
6187 object_wipe(&inventory[i]);
6192 object_copy(&inventory[i], o_ptr);
6194 /* Access new object */
6195 j_ptr = &inventory[i];
6198 j_ptr->next_o_idx = 0;
6200 /* Forget monster */
6201 j_ptr->held_m_idx = 0;
6203 /* Forget location */
6204 j_ptr->iy = j_ptr->ix = 0;
6206 /* Player touches it, and no longer marked */
6207 j_ptr->marked = OM_TOUCHED;
6209 /* Increase the weight */
6210 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6212 /* Count the items */
6215 /* Recalculate bonuses */
6216 p_ptr->update |= (PU_BONUS);
6218 /* Combine and Reorder pack */
6219 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6222 p_ptr->window |= (PW_INVEN);
6224 /* Return the slot */
6230 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6231 * Take off (some of) a non-cursed equipment item
6232 * @param item オブジェクトを外したい所持テーブルのID
6234 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6236 * Note that only one item at a time can be wielded per slot.\n
6237 * Note that taking off an item when "full" may cause that item\n
6238 * to fall to the ground.\n
6239 * Return the inventory slot into which the item is placed.\n
6241 INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
6252 char o_name[MAX_NLEN];
6255 /* Get the item to take off */
6256 o_ptr = &inventory[item];
6259 if (amt <= 0) return (-1);
6262 if (amt > o_ptr->number) amt = o_ptr->number;
6264 /* Get local object */
6267 /* Obtain a local object */
6268 object_copy(q_ptr, o_ptr);
6270 /* Modify quantity */
6271 q_ptr->number = amt;
6273 /* Describe the object */
6274 object_desc(o_name, q_ptr, 0);
6276 /* Took off weapon */
6277 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6278 object_is_melee_weapon(o_ptr))
6280 act = _("を装備からはずした", "You were wielding");
6284 else if (item == INVEN_BOW)
6286 act = _("を装備からはずした", "You were holding");
6289 /* Took off light */
6290 else if (item == INVEN_LITE)
6292 act = _("を光源からはずした", "You were holding");
6295 /* Took off something */
6298 act = _("を装備からはずした", "You were wearing");
6301 /* Modify, Optimize */
6302 inven_item_increase(item, -amt);
6303 inven_item_optimize(item);
6305 /* Carry the object */
6306 slot = inven_carry(q_ptr);
6310 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6312 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6322 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6323 * Drop (some of) a non-cursed inventory/equipment item
6324 * @param item 所持テーブルのID
6325 * @param amt 落としたい個数
6328 * The object will be dropped "near" the current location
6330 void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
6336 char o_name[MAX_NLEN];
6339 /* Access original object */
6340 o_ptr = &inventory[item];
6343 if (amt <= 0) return;
6346 if (amt > o_ptr->number) amt = o_ptr->number;
6349 /* Take off equipment */
6350 if (item >= INVEN_RARM)
6352 /* Take off first */
6353 item = inven_takeoff(item, amt);
6355 /* Access original object */
6356 o_ptr = &inventory[item];
6360 /* Get local object */
6363 /* Obtain local object */
6364 object_copy(q_ptr, o_ptr);
6366 /* Distribute charges of wands or rods */
6367 distribute_charges(o_ptr, q_ptr, amt);
6369 /* Modify quantity */
6370 q_ptr->number = amt;
6372 /* Describe local object */
6373 object_desc(o_name, q_ptr, 0);
6376 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6378 /* Drop it near the player */
6379 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6381 /* Modify, Describe, Optimize */
6382 inven_item_increase(item, -amt);
6383 inven_item_describe(item);
6384 inven_item_optimize(item);
6389 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6390 * Combine items in the pack
6393 * Note special handling of the "overflow" slot
6395 void combine_pack(void)
6400 bool flag = FALSE, combined;
6406 /* Combine the pack (backwards) */
6407 for (i = INVEN_PACK; i > 0; i--)
6410 o_ptr = &inventory[i];
6412 /* Skip empty items */
6413 if (!o_ptr->k_idx) continue;
6415 /* Scan the items above that item */
6416 for (j = 0; j < i; j++)
6421 j_ptr = &inventory[j];
6423 /* Skip empty items */
6424 if (!j_ptr->k_idx) continue;
6427 * Get maximum number of the stack if these
6428 * are similar, get zero otherwise.
6430 max_num = object_similar_part(j_ptr, o_ptr);
6432 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6433 if (max_num && j_ptr->number < max_num)
6435 if (o_ptr->number + j_ptr->number <= max_num)
6440 /* Add together the item counts */
6441 object_absorb(j_ptr, o_ptr);
6443 /* One object is gone */
6446 /* Slide everything down */
6447 for (k = i; k < INVEN_PACK; k++)
6449 /* Structure copy */
6450 inventory[k] = inventory[k+1];
6453 /* Erase the "final" slot */
6454 object_wipe(&inventory[k]);
6458 int old_num = o_ptr->number;
6459 int remain = j_ptr->number + o_ptr->number - max_num;
6461 o_ptr->number -= remain;
6463 /* Add together the item counts */
6464 object_absorb(j_ptr, o_ptr);
6466 o_ptr->number = remain;
6468 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6469 if (o_ptr->tval == TV_ROD)
6471 o_ptr->pval = o_ptr->pval * remain / old_num;
6472 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6475 /* Hack -- if wands are stacking, combine the charges. -LM- */
6476 if (o_ptr->tval == TV_WAND)
6478 o_ptr->pval = o_ptr->pval * remain / old_num;
6483 p_ptr->window |= (PW_INVEN);
6497 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6501 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6502 * Reorder items in the pack
6505 * Note special handling of the "overflow" slot
6507 void reorder_pack(void)
6517 /* Re-order the pack (forwards) */
6518 for (i = 0; i < INVEN_PACK; i++)
6520 /* Mega-Hack -- allow "proper" over-flow */
6521 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6524 o_ptr = &inventory[i];
6526 /* Skip empty slots */
6527 if (!o_ptr->k_idx) continue;
6529 /* Get the "value" of the item */
6530 o_value = object_value(o_ptr);
6532 /* Scan every occupied slot */
6533 for (j = 0; j < INVEN_PACK; j++)
6535 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6538 /* Never move down */
6539 if (j >= i) continue;
6544 /* Get local object */
6547 /* Save a copy of the moving item */
6548 object_copy(q_ptr, &inventory[i]);
6550 /* Slide the objects */
6551 for (k = i; k > j; k--)
6553 /* Slide the item */
6554 object_copy(&inventory[k], &inventory[k-1]);
6557 /* Insert the moving item */
6558 object_copy(&inventory[j], q_ptr);
6561 p_ptr->window |= (PW_INVEN);
6565 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6569 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6570 * Hack -- display an object kind in the current window
6571 * @param k_idx ベースアイテムの参照ID
6574 * Include list of usable spells for readible books
6576 void display_koff(IDX k_idx)
6583 REALM_IDX use_realm;
6585 char o_name[MAX_NLEN];
6588 /* Erase the window */
6589 for (y = 0; y < Term->hgt; y++)
6591 /* Erase the line */
6592 Term_erase(0, y, 255);
6598 /* Get local object */
6601 /* Prepare the object */
6602 object_prep(q_ptr, k_idx);
6605 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6607 /* Mention the object name */
6608 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6610 /* Access the item's sval */
6612 use_realm = tval2realm(q_ptr->tval);
6614 /* Warriors are illiterate */
6615 if (p_ptr->realm1 || p_ptr->realm2)
6617 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6621 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6622 if (!is_magic(use_realm)) return;
6623 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6626 /* Display spells in readible books */
6630 SPELL_IDX spells[64];
6632 /* Extract spells */
6633 for (spell = 0; spell < 32; spell++)
6635 /* Check for this spell */
6636 if (fake_spell_flags[sval] & (1L << spell))
6638 /* Collect this spell */
6639 spells[num++] = spell;
6644 print_spells(0, spells, num, 2, 0, use_realm);
6649 * @brief 警告を放つアイテムを選択する /
6650 * Choose one of items that have warning flag
6651 * Calculate spell damages
6654 object_type *choose_warning_item(void)
6657 int choices[INVEN_TOTAL - INVEN_RARM];
6660 /* Paranoia -- Player has no warning ability */
6661 if (!p_ptr->warning) return NULL;
6663 /* Search Inventory */
6664 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6666 BIT_FLAGS flgs[TR_FLAG_SIZE];
6667 object_type *o_ptr = &inventory[i];
6669 object_flags(o_ptr, flgs);
6670 if (have_flag(flgs, TR_WARNING))
6672 choices[number] = i;
6677 /* Choice one of them */
6678 return number ? &inventory[choices[randint0(number)]] : NULL;
6682 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6683 * Calculate spell damages
6684 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6685 * @param typ 効果属性のID
6687 * @param max 算出した最大ダメージを返すポインタ
6690 static void spell_damcalc(monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
6692 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6693 int rlev = r_ptr->level;
6694 bool ignore_wraith_form = FALSE;
6696 /* Vulnerability, resistance and immunity */
6700 if (p_ptr->immune_elec)
6703 ignore_wraith_form = TRUE;
6707 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6708 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6709 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6710 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6711 if (IS_OPPOSE_ELEC())
6712 dam = (dam + 2) / 3;
6717 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6718 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6722 if (p_ptr->immune_acid)
6725 ignore_wraith_form = TRUE;
6729 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6730 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6731 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6732 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6738 if (p_ptr->immune_cold)
6741 ignore_wraith_form = TRUE;
6745 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6746 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6747 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6748 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6753 if (p_ptr->immune_fire)
6756 ignore_wraith_form = TRUE;
6760 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6761 if (prace_is_(RACE_ENT)) dam += dam / 3;
6762 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6763 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6764 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6769 ignore_wraith_form = TRUE;
6773 if (!p_ptr->blind &&
6774 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6775 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6778 ignore_wraith_form = TRUE;
6783 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6784 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6785 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6788 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6789 * "dam *= 2;" for later "dam /= 2"
6791 if (p_ptr->wraith_form) dam *= 2;
6795 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6798 ignore_wraith_form = TRUE;
6800 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6804 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6808 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6812 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6816 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6820 if (prace_is_(RACE_SPECTRE))
6823 ignore_wraith_form = TRUE;
6825 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6829 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6833 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6837 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6841 if (p_ptr->levitation) dam = (dam * 2) / 3;
6845 if (p_ptr->resist_shard) dam /= 2;
6849 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6850 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6854 if (p_ptr->mimic_form)
6856 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6859 ignore_wraith_form = TRUE;
6864 switch (p_ptr->prace)
6873 ignore_wraith_form = TRUE;
6880 if (p_ptr->align > 10) dam /= 2;
6881 else if (p_ptr->align < -10) dam *= 2;
6885 if (p_ptr->align > 10) dam *= 2;
6889 case GF_BRAIN_SMASH:
6890 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6893 ignore_wraith_form = TRUE;
6901 if (100 + rlev / 2 <= p_ptr->skill_sav)
6904 ignore_wraith_form = TRUE;
6909 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6912 ignore_wraith_form = TRUE;
6917 if (p_ptr->wraith_form && !ignore_wraith_form)
6923 if (dam > *max) *max = dam;
6927 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6928 * Calculate spell damages
6929 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6930 * @param typ 効果属性のID
6931 * @param m_idx 魔法を行使するモンスターのID
6932 * @param max 算出した最大ダメージを返すポインタ
6935 void spell_damcalc_by_spellnum(int spell_num, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
6937 monster_type *m_ptr = &m_list[m_idx];
6938 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
6939 spell_damcalc(m_ptr, typ, dam, max);
6943 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
6944 * Calculate blow damages
6945 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
6946 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
6947 * @return 算出された最大ダメージを返す。
6949 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6951 int dam = blow_ptr->d_dice * blow_ptr->d_side;
6953 bool check_wraith_form = TRUE;
6955 if (blow_ptr->method != RBM_EXPLODE)
6957 int ac = p_ptr->ac + p_ptr->to_a;
6959 switch (blow_ptr->effect)
6963 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
6964 dam = MAX(dam, tmp_dam * 2);
6970 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
6974 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
6976 check_wraith_form = FALSE;
6980 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
6982 check_wraith_form = FALSE;
6986 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
6988 check_wraith_form = FALSE;
6992 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
6994 check_wraith_form = FALSE;
6999 check_wraith_form = FALSE;
7003 if (check_wraith_form && p_ptr->wraith_form)
7011 dam = (dam + 1) / 2;
7012 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7020 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7021 * Examine the grid (xx,yy) and warn the player if there are any danger
7022 * @param xx 危険性を調査するマスのX座標
7023 * @param yy 危険性を調査するマスのY座標
7024 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7026 bool process_warning(int xx, int yy)
7030 char o_name[MAX_NLEN];
7032 #define WARNING_AWARE_RANGE 12
7034 static int old_damage = 0;
7036 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7038 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7041 monster_type *m_ptr;
7042 monster_race *r_ptr;
7044 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7046 c_ptr = &cave[my][mx];
7048 if (!c_ptr->m_idx) continue;
7050 m_ptr = &m_list[c_ptr->m_idx];
7052 if (MON_CSLEEP(m_ptr)) continue;
7053 if (!is_hostile(m_ptr)) continue;
7055 r_ptr = &r_info[m_ptr->r_idx];
7057 /* Monster spells (only powerful ones)*/
7058 if (projectable(my, mx, yy, xx))
7060 u32b f4 = r_ptr->flags4;
7061 u32b f5 = r_ptr->a_ability_flags1;
7062 u32b f6 = r_ptr->a_ability_flags2;
7064 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7066 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7067 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7068 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7069 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7070 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7071 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7073 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7074 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7075 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7076 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7077 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7078 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7079 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7080 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7081 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7082 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7083 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7084 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7085 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7086 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7087 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7088 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7089 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7090 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7091 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7092 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7093 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7094 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7095 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7098 /* Monster melee attacks */
7099 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7101 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7105 for (m = 0; m < 4; m++)
7107 /* Skip non-attacks */
7108 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7110 /* Extract the attack info */
7111 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7112 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7114 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7118 /* Contribution from this monster */
7119 dam_max += dam_max0;
7123 /* Prevent excessive warning */
7124 if (dam_max > old_damage)
7126 old_damage = dam_max * 3 / 2;
7128 if (dam_max > p_ptr->chp / 2)
7130 object_type *o_ptr = choose_warning_item();
7133 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7135 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7136 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7139 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7142 else old_damage = old_damage / 2;
7144 c_ptr = &cave[yy][xx];
7145 if (((!easy_disarm && is_trap(c_ptr->feat))
7146 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7148 object_type *o_ptr = choose_warning_item();
7151 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7153 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7154 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7156 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7163 * エッセンス情報の構造体 / A structure for smithing
7166 int add; /* TR flag number or special essence id */
7167 cptr add_name; /* Name of this ability */
7168 ESSENCE_IDX type; /* Menu number */
7169 int essence; /* Index for carrying essences */
7170 int value; /* Needed value to add this ability */
7175 * エッセンス情報テーブル Smithing type data for Weapon smith
7178 static essence_type essence_info[] =
7180 {TR_STR, "腕力", 4, TR_STR, 20},
7181 {TR_INT, "知能", 4, TR_INT, 20},
7182 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7183 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7184 {TR_CON, "耐久力", 4, TR_CON, 20},
7185 {TR_CHR, "魅力", 4, TR_CHR, 20},
7186 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7187 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7188 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7189 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7190 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7191 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7192 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7193 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7194 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7195 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7196 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7197 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7198 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7199 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7200 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7201 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7202 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7203 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7204 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7205 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7206 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7207 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7208 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7209 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7210 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7211 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7212 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7213 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7214 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7215 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7216 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7217 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7218 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7219 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7220 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7221 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7222 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7223 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7224 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7225 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7226 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7227 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7228 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7229 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7230 {TR_SH_FIRE, "", 0, -2, 0},
7231 {TR_SH_ELEC, "", 0, -2, 0},
7232 {TR_SH_COLD, "", 0, -2, 0},
7233 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7234 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7235 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7236 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7237 {TR_LITE_2, "", 0, -2, 0},
7238 {TR_LITE_3, "", 0, -2, 0},
7239 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7240 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7241 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7242 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7243 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7245 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7246 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7247 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7248 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7249 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7250 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7251 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7252 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7253 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7254 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7255 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7256 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7257 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7258 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7259 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7260 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7261 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7262 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7264 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7265 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7266 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7267 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7268 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7269 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7270 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7271 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7273 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7274 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7275 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7276 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7277 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7278 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7279 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7280 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7281 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7282 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7283 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7284 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7286 {-1, NULL, 0, -1, 0}
7289 static essence_type essence_info[] =
7291 {TR_STR, "strength", 4, TR_STR, 20},
7292 {TR_INT, "intelligence", 4, TR_INT, 20},
7293 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7294 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7295 {TR_CON, "constitution", 4, TR_CON, 20},
7296 {TR_CHR, "charisma", 4, TR_CHR, 20},
7297 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7298 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7299 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7300 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7301 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7302 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7303 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7304 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7305 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7306 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7307 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7308 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7309 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7310 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7311 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7312 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7313 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7314 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7315 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7316 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7317 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7318 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7319 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7320 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7321 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7322 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7323 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7324 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7325 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7326 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7327 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7328 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7329 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7330 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7331 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7332 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7333 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7334 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7335 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7336 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7337 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7338 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7339 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7340 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7341 {TR_SH_FIRE, "", 0, -2, 0},
7342 {TR_SH_ELEC, "", 0, -2, 0},
7343 {TR_SH_COLD, "", 0, -2, 0},
7344 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7345 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7346 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7347 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7348 {TR_LITE_2, "", 0, -2, 0},
7349 {TR_LITE_3, "", 0, -2, 0},
7350 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7351 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7352 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7353 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7354 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7356 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7357 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7358 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7359 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7360 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7361 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7362 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7363 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7364 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7365 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7366 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7367 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7368 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7369 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7370 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7371 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7372 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7373 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7375 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7376 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7377 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7378 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7379 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7380 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7381 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7382 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7384 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7385 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7386 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7387 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7388 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7389 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7390 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7391 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7392 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7393 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7394 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7395 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7397 {-1, NULL, 0, -1, 0}
7403 * エッセンス名テーブル / Essense names for Weapon smith
7406 cptr essence_name[] =
7509 cptr essence_name[] =
7612 * @brief 所持しているエッセンス一覧を表示する
7615 static void display_essence(void)
7620 for (i = 1; i < 22; i++)
7624 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7625 "Essence Num Essence Num Essence Num "), 1, 8);
7626 for (i = 0; essence_name[i]; i++)
7628 if (!essence_name[i][0]) continue;
7629 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7632 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7642 static void drain_essence(void)
7644 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7648 bool observe = FALSE;
7649 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
7650 TIME_EFFECT old_timeout;
7651 BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7657 OBJECT_IDX next_o_idx;
7660 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7663 item_tester_hook = object_is_weapon_armour_ammo;
7664 item_tester_no_ryoute = TRUE;
7667 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7668 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7670 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7672 /* Get the item (in the pack) */
7675 o_ptr = &inventory[item];
7678 /* Get the item (on the floor) */
7681 o_ptr = &o_list[0 - item];
7684 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7686 char o_name[MAX_NLEN];
7687 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7688 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7691 p_ptr->energy_use = 100;
7693 object_flags(o_ptr, old_flgs);
7694 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7695 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7696 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7697 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7698 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7699 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7700 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7701 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7702 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7704 old_to_a = o_ptr->to_a;
7706 old_to_h = o_ptr->to_h;
7707 old_to_d = o_ptr->to_d;
7710 old_pval = o_ptr->pval;
7711 old_name2 = o_ptr->name2;
7712 old_timeout = o_ptr->timeout;
7713 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7714 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7715 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7716 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7717 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7718 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7719 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7720 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7721 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7722 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7723 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7724 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7725 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7726 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7727 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7728 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7729 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7730 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7731 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7735 next_o_idx = o_ptr->next_o_idx;
7736 marked = o_ptr->marked;
7737 weight = o_ptr->weight;
7738 number = o_ptr->number;
7740 object_prep(o_ptr, o_ptr->k_idx);
7744 o_ptr->next_o_idx=next_o_idx;
7745 o_ptr->marked=marked;
7746 o_ptr->number = number;
7747 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7748 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7749 o_ptr->ident |= (IDENT_MENTAL);
7750 object_aware(o_ptr);
7751 object_known(o_ptr);
7753 object_flags(o_ptr, new_flgs);
7755 for (i = 0; essence_info[i].add_name; i++)
7757 essence_type *es_ptr = &essence_info[i];
7758 PARAMETER_VALUE pval = 0;
7760 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7761 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7763 if (es_ptr->add < TR_FLAG_MAX &&
7764 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7765 have_flag(old_flgs, es_ptr->add))
7769 drain_value[es_ptr->essence] += 10 * pval;
7771 else if (es_ptr->essence != -2)
7773 drain_value[es_ptr->essence] += 10;
7775 else if (es_ptr->add == TR_SH_FIRE)
7777 drain_value[TR_BRAND_FIRE] += 10;
7778 drain_value[TR_RES_FIRE] += 10;
7780 else if (es_ptr->add == TR_SH_ELEC)
7782 drain_value[TR_BRAND_ELEC] += 10;
7783 drain_value[TR_RES_ELEC] += 10;
7785 else if (es_ptr->add == TR_SH_COLD)
7787 drain_value[TR_BRAND_COLD] += 10;
7788 drain_value[TR_RES_COLD] += 10;
7790 else if (es_ptr->add == TR_LITE_2)
7792 drain_value[TR_LITE_1] += 20;
7794 else if (es_ptr->add == TR_LITE_3)
7796 drain_value[TR_LITE_1] += 30;
7801 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7803 drain_value[TR_INT] += 5;
7804 drain_value[TR_WIS] += 5;
7806 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7808 drain_value[TR_BRAND_POIS] += 5;
7809 drain_value[TR_BRAND_ACID] += 5;
7810 drain_value[TR_BRAND_ELEC] += 5;
7811 drain_value[TR_BRAND_FIRE] += 5;
7812 drain_value[TR_BRAND_COLD] += 5;
7814 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7816 drain_value[TR_INT] += 10;
7818 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7820 drain_value[TR_STR] += 10;
7822 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7824 drain_value[TR_DEX] += 10;
7826 if (old_name2 == EGO_2WEAPON)
7828 drain_value[TR_DEX] += 20;
7830 if (object_is_weapon_ammo(o_ptr))
7832 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7834 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7836 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7837 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7838 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7839 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7841 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7843 drain_value[i] *= number;
7844 drain_value[i] = drain_value[i] * dec / 4;
7845 drain_value[i] = MAX(drain_value[i], 0);
7846 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7854 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7858 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7860 for (i = 0; essence_name[i]; i++)
7862 if (!essence_name[i][0]) continue;
7863 if (!drain_value[i]) continue;
7865 p_ptr->magic_num1[i] += drain_value[i];
7866 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7868 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7872 /* Apply autodestroy/inscription to the drained item */
7873 autopick_alter_item(item, TRUE);
7875 /* Combine the pack */
7876 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7879 p_ptr->window |= (PW_INVEN);
7883 * @brief 付加するエッセンスの大別を選択する
7884 * @return 選んだエッセンスの大別ID
7886 static COMMAND_CODE choose_essence(void)
7888 COMMAND_CODE mode = 0;
7890 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
7893 cptr menu_name[] = {
7903 cptr menu_name[] = {
7913 const COMMAND_CODE mode_max = 7;
7916 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7919 #endif /* ALLOW_REPEAT */
7928 for (i = 0; i < mode_max; i++)
7930 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
7931 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
7933 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
7934 prt("Choose from menu.", 0, 0);
7953 menu_line += mode_max - 1;
7962 if (menu_line > mode_max) menu_line -= mode_max;
7973 for (i = 0; i < mode_max; i++)
7974 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
7976 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
7982 if (isupper(choice)) choice = (char)tolower(choice);
7984 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
7985 mode = (int)choice - 'a' + 1;
7992 #endif /* ALLOW_REPEAT */
7997 * @brief エッセンスを実際に付加する
7998 * @param mode エッセンスの大別ID
8001 static void add_essence(ESSENCE_IDX mode)
8013 char o_name[MAX_NLEN];
8015 essence_type *es_ptr;
8016 bool able[22] = { 0 };
8018 int menu_line = (use_menu ? 1 : 0);
8020 for (i = 0; essence_info[i].add_name; i++)
8022 es_ptr = &essence_info[i];
8024 if (es_ptr->type != mode) continue;
8029 if (!repeat_pull(&i) || i<0 || i>=max_num)
8031 #endif /* ALLOW_REPEAT */
8034 /* Nothing chosen yet */
8040 /* Build a prompt */
8041 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8042 if (use_menu) screen_save();
8044 /* Get a spell from the user */
8046 choice = (always_show_list || use_menu) ? ESCAPE:1;
8049 if( choice==ESCAPE ) choice = ' ';
8050 else if( !get_com(out_val, &choice, FALSE) )break;
8052 if (use_menu && choice != ' ')
8066 menu_line += (max_num-1);
8089 menu_line = max_num;
8103 if (menu_line > max_num) menu_line -= max_num;
8105 /* Request redraw */
8106 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8109 if (!redraw || use_menu)
8113 char dummy[80], dummy2[80];
8121 /* Save the screen */
8122 if (!use_menu) screen_save();
8124 for (y = 1; y < 24; y++)
8127 /* Print header(s) */
8129 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8132 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8135 for (ctr = 0; ctr < max_num; ctr++)
8137 es_ptr = &essence_info[num[ctr]];
8141 if (ctr == (menu_line-1))
8142 strcpy(dummy, _("》 ", "> "));
8143 else strcpy(dummy, " ");
8146 /* letter/number for power selection */
8149 sprintf(dummy, "%c) ",I2A(ctr));
8152 strcat(dummy, es_ptr->add_name);
8157 if (es_ptr->essence != -1)
8159 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8160 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8166 case ESSENCE_SH_FIRE:
8167 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8168 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8169 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8171 case ESSENCE_SH_ELEC:
8172 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8173 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8174 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8176 case ESSENCE_SH_COLD:
8177 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8178 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8179 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8181 case ESSENCE_RESISTANCE:
8182 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8183 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8184 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8185 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8186 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8188 case ESSENCE_SUSTAIN:
8189 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8190 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8191 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8192 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8193 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8198 if (!able[ctr]) col = TERM_RED;
8200 if (es_ptr->essence != -1)
8202 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8206 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8209 c_prt(col, dummy2, ctr+2, x);
8219 /* Restore the screen */
8230 ask = (isupper(choice));
8233 if (ask) choice = (char)tolower(choice);
8235 /* Extract request */
8236 i = (islower(choice) ? A2I(choice) : -1);
8239 /* Totally Illegal */
8240 if ((i < 0) || (i >= max_num) || !able[i])
8252 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8254 /* Belay that order */
8255 if (!get_check(tmp_val)) continue;
8262 /* Restore the screen */
8263 if (redraw) screen_load();
8270 #endif /* ALLOW_REPEAT */
8272 es_ptr = &essence_info[num[i]];
8274 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8275 item_tester_tval = TV_GLOVES;
8276 else if (mode == 1 || mode == 5)
8277 item_tester_hook = item_tester_hook_melee_ammo;
8278 else if (es_ptr->add == ESSENCE_ATTACK)
8279 item_tester_hook = object_allow_enchant_weapon;
8280 else if (es_ptr->add == ESSENCE_AC)
8281 item_tester_hook = object_is_armour;
8283 item_tester_hook = object_is_weapon_armour_ammo;
8284 item_tester_no_ryoute = TRUE;
8287 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8288 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8290 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8292 /* Get the item (in the pack) */
8295 o_ptr = &inventory[item];
8298 /* Get the item (on the floor) */
8301 o_ptr = &o_list[0 - item];
8304 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8306 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8310 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8312 use_essence = es_ptr->value;
8313 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8314 if (o_ptr->number > 1)
8316 use_essence *= o_ptr->number;
8317 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8320 if (es_ptr->essence != -1)
8322 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8324 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8327 if (is_pval_flag(es_ptr->add))
8329 if (o_ptr->pval < 0)
8331 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8334 else if (es_ptr->add == TR_BLOWS)
8336 if (o_ptr->pval > 1)
8338 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8342 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8344 else if (o_ptr->pval > 0)
8346 use_essence *= o_ptr->pval;
8347 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8353 PARAMETER_VALUE pval;
8354 PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8356 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8357 strcpy(tmp_val, "1");
8359 if (!get_string(tmp, tmp_val, 1)) return;
8360 pval = (PARAMETER_VALUE)atoi(tmp_val);
8361 if (pval > limit) pval = limit;
8362 else if (pval < 1) pval = 1;
8363 o_ptr->pval += pval;
8364 use_essence *= pval;
8365 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8368 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8370 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8374 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8381 strcpy(tmp_val, "1");
8382 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8383 val = atoi(tmp_val);
8384 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8385 else if (val < 1) val = 1;
8387 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8388 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8390 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8393 get_to_h = ((val+1)/2+randint0(val/2+1));
8394 get_to_d = ((val+1)/2+randint0(val/2+1));
8395 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8396 o_ptr->to_h += get_to_h;
8397 o_ptr->to_d += get_to_d;
8399 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8400 if (es_ptr->add == ESSENCE_ATTACK)
8402 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8404 msg_print(_("改良に失敗した。", "You failed to enchant."));
8405 p_ptr->energy_use = 100;
8410 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8411 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8414 else if (es_ptr->add == ESSENCE_AC)
8416 if (o_ptr->to_a >= p_ptr->lev/5+5)
8418 msg_print(_("改良に失敗した。", "You failed to enchant."));
8419 p_ptr->energy_use = 100;
8424 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8429 o_ptr->xtra3 = es_ptr->add + 1;
8434 bool success = TRUE;
8438 case ESSENCE_SH_FIRE:
8439 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8444 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8445 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8447 case ESSENCE_SH_ELEC:
8448 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8453 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8454 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8456 case ESSENCE_SH_COLD:
8457 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8462 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8463 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8465 case ESSENCE_RESISTANCE:
8466 case ESSENCE_SUSTAIN:
8467 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))
8472 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8473 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8474 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8475 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8480 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8483 if (es_ptr->add == ESSENCE_SUSTAIN)
8485 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8486 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8487 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8488 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8492 o_ptr->xtra3 = es_ptr->add + 1;
8496 p_ptr->energy_use = 100;
8499 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8501 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8504 /* Combine the pack */
8505 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8508 p_ptr->window |= (PW_INVEN);
8515 static void erase_essence(void)
8520 char o_name[MAX_NLEN];
8521 BIT_FLAGS flgs[TR_FLAG_SIZE];
8523 item_tester_hook = object_is_smith;
8526 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8527 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8529 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8531 /* Get the item (in the pack) */
8534 o_ptr = &inventory[item];
8537 /* Get the item (on the floor) */
8540 o_ptr = &o_list[0 - item];
8543 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8544 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8546 p_ptr->energy_use = 100;
8548 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8550 o_ptr->to_h -= (o_ptr->xtra4>>8);
8551 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8553 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8554 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8557 object_flags(o_ptr, flgs);
8558 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8559 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8561 /* Combine the pack */
8562 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8565 p_ptr->window |= (PW_INVEN);
8569 * @brief 鍛冶コマンドのメインルーチン
8570 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8573 void do_cmd_kaji(bool only_browse)
8575 COMMAND_CODE mode = 0;
8578 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
8582 if (p_ptr->confused)
8584 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8589 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8594 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8600 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8602 #endif /* ALLOW_REPEAT */
8604 if (only_browse) screen_save();
8606 if (!only_browse) screen_save();
8612 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8613 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8614 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8615 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8616 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8617 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8619 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8620 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8621 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8622 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8623 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8624 prt(format("Choose command from menu."), 0, 0);
8651 if (menu_line > 5) menu_line -= 5;
8660 prt(" a) エッセンス一覧", 2, 14);
8661 prt(" b) エッセンス抽出", 3, 14);
8662 prt(" c) エッセンス消去", 4, 14);
8663 prt(" d) エッセンス付加", 5, 14);
8664 prt(" e) 武器/防具強化", 6, 14);
8665 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8667 prt(" a) List essences", 2, 14);
8668 prt(" b) Extract essence", 3, 14);
8669 prt(" c) Remove essence", 4, 14);
8670 prt(" d) Add essence", 5, 14);
8671 prt(" e) Enchant weapon/armor", 6, 14);
8672 if (!get_com("Command :", &choice, TRUE))
8709 /* Clear lines, position cursor (really should use strlen here) */
8710 Term_erase(14, 21, 255);
8711 Term_erase(14, 20, 255);
8712 Term_erase(14, 19, 255);
8713 Term_erase(14, 18, 255);
8714 Term_erase(14, 17, 255);
8715 Term_erase(14, 16, 255);
8717 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8718 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8720 prt(&temp[j], line, 15);
8725 if (!only_browse) screen_load();
8726 } while (only_browse);
8730 #endif /* ALLOW_REPEAT */
8734 case 1: display_essence();break;
8735 case 2: drain_essence();break;
8736 case 3: erase_essence();break;
8738 mode = choose_essence();
8743 case 5: add_essence(10);break;
8749 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8750 * Torches have special abilities when they are flaming.
8751 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8752 * @param flgs 特別に追加するフラグを返す参照ポインタ
8755 void torch_flags(object_type *o_ptr, u32b *flgs)
8757 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8759 if (o_ptr->xtra4 > 0)
8761 add_flag(flgs, TR_BRAND_FIRE);
8762 add_flag(flgs, TR_KILL_UNDEAD);
8763 add_flag(flgs, TR_THROW);
8769 * @brief 投擲時たいまつにダイスを与える。
8770 * Torches have special abilities when they are flaming.
8771 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8772 * @param dd 特別なダイス数を返す参照ポインタ
8773 * @param ds 特別なダイス面数を返す参照ポインタ
8776 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8778 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8780 if (o_ptr->xtra4 > 0)
8789 * @brief 投擲時命中したたいまつの寿命を縮める。
8790 * Torches have special abilities when they are flaming.
8791 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8794 void torch_lost_fuel(object_type *o_ptr)
8796 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8798 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8799 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;