3 * @brief オブジェクトの実装 / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
16 static void one_sustain(object_type *o_ptr);
19 static cptr const kaji_tips[5] =
22 "現在持っているエッセンスの一覧を表示する。",
23 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
24 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
25 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
26 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
28 "Display essences you have.",
29 "Extract essences from an item. The item become non magical.",
30 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
31 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
32 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
37 * @brief 対象のオブジェクトにランダムな能力維持を一つ付加する。/ Choose one random sustain
39 * @param o_ptr 対象のオブジェクト構造体ポインタ
42 static void one_sustain(object_type *o_ptr)
46 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
47 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
48 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
49 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
50 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
51 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
56 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
57 * @param o_idx 削除対象のオブジェクト構造体ポインタ
60 void excise_object_idx(int o_idx)
64 s16b this_o_idx, next_o_idx = 0;
70 j_ptr = &o_list[o_idx];
73 if (j_ptr->held_m_idx)
78 m_ptr = &m_list[j_ptr->held_m_idx];
80 /* Scan all objects in the grid */
81 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
86 o_ptr = &o_list[this_o_idx];
88 /* Acquire next object */
89 next_o_idx = o_ptr->next_o_idx;
92 if (this_o_idx == o_idx)
97 /* Remove from list */
98 m_ptr->hold_o_idx = next_o_idx;
106 /* Previous object */
107 k_ptr = &o_list[prev_o_idx];
109 /* Remove from list */
110 k_ptr->next_o_idx = next_o_idx;
113 /* Forget next pointer */
114 o_ptr->next_o_idx = 0;
120 /* Save prev_o_idx */
121 prev_o_idx = this_o_idx;
136 /* Scan all objects in the grid */
137 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
142 o_ptr = &o_list[this_o_idx];
144 /* Acquire next object */
145 next_o_idx = o_ptr->next_o_idx;
148 if (this_o_idx == o_idx)
153 /* Remove from list */
154 c_ptr->o_idx = next_o_idx;
162 /* Previous object */
163 k_ptr = &o_list[prev_o_idx];
165 /* Remove from list */
166 k_ptr->next_o_idx = next_o_idx;
169 /* Forget next pointer */
170 o_ptr->next_o_idx = 0;
176 /* Save prev_o_idx */
177 prev_o_idx = this_o_idx;
183 * @brief オブジェクトを削除する /
184 * Delete a dungeon object
185 * @param o_idx 削除対象のオブジェクト構造体ポインタ
188 * Handle "stacks" of objects correctly.
190 void delete_object_idx(int o_idx)
195 excise_object_idx(o_idx);
198 j_ptr = &o_list[o_idx];
201 if (!(j_ptr->held_m_idx))
213 /* Wipe the object */
222 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
223 * Delete a dungeon object
224 * @param y 削除したフロアマスのY座標
225 * @param x 削除したフロアマスのX座標
228 void delete_object(int y, int x)
232 s16b this_o_idx, next_o_idx = 0;
235 /* Refuse "illegal" locations */
236 if (!in_bounds(y, x)) return;
242 /* Scan all objects in the grid */
243 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
248 o_ptr = &o_list[this_o_idx];
250 /* Acquire next object */
251 next_o_idx = o_ptr->next_o_idx;
253 /* Wipe the object */
260 /* Objects are gone */
269 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
270 * Move an object from index i1 to index i2 in the object list
271 * @param i1 整理したい配列の始点
272 * @param i2 整理したい配列の終点
275 static void compact_objects_aux(IDX i1, IDX i2)
282 if (i1 == i2) return;
286 for (i = 1; i < o_max; i++)
291 /* Skip "dead" objects */
292 if (!o_ptr->k_idx) continue;
294 /* Repair "next" pointers */
295 if (o_ptr->next_o_idx == i1)
298 o_ptr->next_o_idx = i2;
308 if (o_ptr->held_m_idx)
312 /* Acquire monster */
313 m_ptr = &m_list[o_ptr->held_m_idx];
316 if (m_ptr->hold_o_idx == i1)
319 m_ptr->hold_o_idx = i2;
328 /* Acquire location */
336 if (c_ptr->o_idx == i1)
345 o_list[i2] = o_list[i1];
353 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
354 * Compact and Reorder the object list.
355 * @param size 最低でも減らしたいオブジェクト数の水準
359 * This function can be very dangerous, use with caution!\n
361 * When actually "compacting" objects, we base the saving throw on a\n
362 * combination of object level, distance from player, and current\n
365 * After "compacting" (if needed), we "reorder" the objects into a more\n
366 * compact order, and we reset the allocation info, and the "live" array.\n
368 void compact_objects(int size)
372 int cur_lev, cur_dis, chance;
380 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
383 p_ptr->redraw |= (PR_MAP);
386 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
390 /* Compact at least 'size' objects */
391 for (num = 0, cnt = 1; num < size; cnt++)
393 /* Get more vicious each iteration */
396 /* Get closer each iteration */
397 cur_dis = 5 * (20 - cnt);
399 /* Examine the objects */
400 for (i = 1; i < o_max; i++)
404 /* Skip dead objects */
405 if (!o_ptr->k_idx) continue;
407 /* Hack -- High level objects start out "immune" */
408 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
411 if (o_ptr->held_m_idx)
415 /* Acquire monster */
416 m_ptr = &m_list[o_ptr->held_m_idx];
418 /* Get the location */
422 /* Monsters protect their objects */
423 if (randint0(100) < 90) continue;
429 /* Get the location */
434 /* Nearby objects start out "immune" */
435 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
440 /* Hack -- only compact artifacts in emergencies */
441 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
442 (cnt < 1000)) chance = 100;
444 /* Apply the saving throw */
445 if (randint0(100) < chance) continue;
447 /* Delete the object */
448 delete_object_idx(i);
456 /* Excise dead objects (backwards!) */
457 for (i = o_max - 1; i >= 1; i--)
461 /* Skip real objects */
462 if (o_ptr->k_idx) continue;
464 /* Move last object into open hole */
465 compact_objects_aux(o_max - 1, i);
467 /* Compress "o_max" */
474 * @brief グローバルオブジェクト配列を初期化する /
475 * Delete all the items when player leaves the level
476 * @note we do NOT visually reflect these (irrelevant) changes
478 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
479 * and the "m_ptr->next_o_idx" field for every monster, since
480 * we know we are clearing every object. Technically, we only
481 * clear those fields for grids/monsters containing objects,
482 * and we clear it once for every such object.
485 void wipe_o_list(void)
489 /* Delete the existing objects */
490 for (i = 1; i < o_max; i++)
492 object_type *o_ptr = &o_list[i];
494 /* Skip dead objects */
495 if (!o_ptr->k_idx) continue;
497 /* Mega-Hack -- preserve artifacts */
498 if (!character_dungeon || preserve_mode)
500 /* Hack -- Preserve unknown artifacts */
501 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
503 /* Mega-Hack -- Preserve the artifact */
504 a_info[o_ptr->name1].cur_num = 0;
509 if (o_ptr->held_m_idx)
514 m_ptr = &m_list[o_ptr->held_m_idx];
516 /* Hack -- see above */
517 m_ptr->hold_o_idx = 0;
525 /* Access location */
532 /* Hack -- see above */
536 /* Wipe the object */
549 * @brief グローバルオブジェクト配列から空きを取得する /
550 * Acquires and returns the index of a "free" object.
551 * @return 開いているオブジェクト要素のID
553 * This routine should almost never fail, but in case it does,
554 * we must be sure to handle "failure" of this routine.
561 /* Initial allocation */
562 if (o_max < max_o_idx)
567 /* Expand object array */
573 /* Use this object */
578 /* Recycle dead objects */
579 for (i = 1; i < o_max; i++)
586 /* Skip live objects */
587 if (o_ptr->k_idx) continue;
592 /* Use this object */
597 /* Warn the player (except during dungeon creation) */
598 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
606 * @brief オブジェクト生成テーブルに生成制約を加える /
607 * Apply a "object restriction function" to the "object allocation table"
609 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
611 static errr get_obj_num_prep(void)
616 alloc_entry *table = alloc_kind_table;
618 /* Scan the allocation table */
619 for (i = 0; i < alloc_kind_size; i++)
621 /* Accept objects which pass the restriction, if any */
622 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
624 /* Accept this object */
625 table[i].prob2 = table[i].prob1;
628 /* Do not use this object */
631 /* Decline this object */
642 * @brief オブジェクト生成テーブルからアイテムを取得する /
643 * Choose an object kind that seems "appropriate" to the given level
645 * @return 選ばれたオブジェクトベースID
647 * This function uses the "prob2" field of the "object allocation table",\n
648 * and various local information, to calculate the "prob3" field of the\n
649 * same table, which is then used to choose an "appropriate" object, in\n
650 * a relatively efficient manner.\n
652 * It is (slightly) more likely to acquire an object of the given level\n
653 * than one of a lower level. This is done by choosing several objects\n
654 * appropriate to the given level and keeping the "hardest" one.\n
656 * Note that if no objects are "appropriate", then this function will\n
657 * fail, and return zero, but this should *almost* never happen.\n
659 s16b get_obj_num(int level)
665 alloc_entry *table = alloc_kind_table;
667 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
670 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
672 /* Occasional "boost" */
673 if (one_in_(GREAT_OBJ))
675 /* What a bizarre calculation */
676 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
683 /* Process probabilities */
684 for (i = 0; i < alloc_kind_size; i++)
686 /* Objects are sorted by depth */
687 if (table[i].level > level) break;
692 /* Access the index */
693 k_idx = table[i].index;
695 /* Access the actual kind */
696 k_ptr = &k_info[k_idx];
698 /* Hack -- prevent embedded chests */
699 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
702 table[i].prob3 = table[i].prob2;
705 total += table[i].prob3;
708 /* No legal objects */
709 if (total <= 0) return (0);
713 value = randint0(total);
715 /* Find the object */
716 for (i = 0; i < alloc_kind_size; i++)
718 /* Found the entry */
719 if (value < table[i].prob3) break;
722 value = value - table[i].prob3;
729 /* Try for a "better" object once (50%) or twice (10%) */
736 value = randint0(total);
738 /* Find the object */
739 for (i = 0; i < alloc_kind_size; i++)
741 /* Found the entry */
742 if (value < table[i].prob3) break;
745 value = value - table[i].prob3;
748 /* Keep the "best" one */
749 if (table[i].level < table[j].level) i = j;
752 /* Try for a "better" object twice (10%) */
759 value = randint0(total);
761 /* Find the object */
762 for (i = 0; i < alloc_kind_size; i++)
764 /* Found the entry */
765 if (value < table[i].prob3) break;
768 value = value - table[i].prob3;
771 /* Keep the "best" one */
772 if (table[i].level < table[j].level) i = j;
777 return (table[i].index);
782 * @brief オブジェクトを鑑定済にする /
783 * Known is true when the "attributes" of an object are "known".
784 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
786 * These include tohit, todam, toac, cost, and pval (charges).\n
788 * Note that "knowing" an object gives you everything that an "awareness"\n
789 * gives you, and much more. In fact, the player is always "aware" of any\n
790 * item of which he has full "knowledge".\n
792 * But having full knowledge of, say, one "wand of wonder", does not, by\n
793 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
794 * It happens that most "identify" routines (including "buying from a shop")\n
795 * will make the player "aware" of the object as well as fully "know" it.\n
797 * This routine also removes any inscriptions generated by "feelings".\n
799 void object_known(object_type *o_ptr)
801 /* Remove "default inscriptions" */
802 o_ptr->feeling = FEEL_NONE;
804 /* Clear the "Felt" info */
805 o_ptr->ident &= ~(IDENT_SENSE);
807 /* Clear the "Empty" info */
808 o_ptr->ident &= ~(IDENT_EMPTY);
810 /* Now we know about the item */
811 o_ptr->ident |= (IDENT_KNOWN);
815 * @brief オブジェクトを*鑑定*済にする /
816 * The player is now aware of the effects of the given object.
817 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
820 void object_aware(object_type *o_ptr)
822 bool mihanmei = !object_is_aware(o_ptr);
824 /* Fully aware of the effects */
825 k_info[o_ptr->k_idx].aware = TRUE;
827 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
828 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
832 char o_name[MAX_NLEN];
835 object_copy(q_ptr, o_ptr);
838 object_desc(o_name, q_ptr, OD_NAME_ONLY);
840 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
846 * @brief オブジェクトを試行済にする /
847 * Something has been "sampled"
848 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
851 void object_tried(object_type *o_ptr)
853 /* Mark it as tried (even if "aware") */
854 k_info[o_ptr->k_idx].tried = TRUE;
859 * @brief 未鑑定なベースアイテムの基本価格を返す /
860 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
861 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
862 * @return オブジェクトの未鑑定価格
864 static s32b object_value_base(object_type *o_ptr)
866 /* Aware item -- use template cost */
867 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
869 /* Analyze the type */
874 case TV_FOOD: return (5L);
876 /* Un-aware Potions */
877 case TV_POTION: return (20L);
879 /* Un-aware Scrolls */
880 case TV_SCROLL: return (20L);
882 /* Un-aware Staffs */
883 case TV_STAFF: return (70L);
886 case TV_WAND: return (50L);
889 case TV_ROD: return (90L);
892 case TV_RING: return (45L);
894 /* Un-aware Amulets */
895 case TV_AMULET: return (45L);
897 /* Figurines, relative to monster level */
900 int level = r_info[o_ptr->pval].level;
901 if (level < 20) return level*50L;
902 else if (level < 30) return 1000+(level-20)*150L;
903 else if (level < 40) return 2500+(level-30)*350L;
904 else if (level < 50) return 6000+(level-40)*800L;
905 else return 14000+(level-50)*2000L;
909 if (!o_ptr->pval) return 1000L;
910 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
913 /* Paranoia -- Oops */
919 * @brief オブジェクトのフラグ類から価格を算出する /
920 * Return the value of the flags the object has...
921 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
922 * @param plusses フラグに与える価格の基本重み
923 * @return オブジェクトのフラグ価格
925 s32b flag_cost(object_type *o_ptr, int plusses)
928 u32b flgs[TR_FLAG_SIZE];
932 object_kind *k_ptr = &k_info[o_ptr->k_idx];
934 object_flags(o_ptr, flgs);
937 * Exclude fixed flags of the base item.
938 * pval bonuses of base item will be treated later.
940 for (i = 0; i < TR_FLAG_SIZE; i++)
941 flgs[i] &= ~(k_ptr->flags[i]);
943 /* Exclude fixed flags of the fixed artifact. */
944 if (object_is_fixed_artifact(o_ptr))
946 artifact_type *a_ptr = &a_info[o_ptr->name1];
948 for (i = 0; i < TR_FLAG_SIZE; i++)
949 flgs[i] &= ~(a_ptr->flags[i]);
952 /* Exclude fixed flags of the ego-item. */
953 else if (object_is_ego(o_ptr))
955 ego_item_type *e_ptr = &e_info[o_ptr->name2];
957 for (i = 0; i < TR_FLAG_SIZE; i++)
958 flgs[i] &= ~(e_ptr->flags[i]);
963 * Calucurate values of remaining flags
965 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
966 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
967 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
968 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
969 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
970 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
971 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
972 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
973 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
974 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
975 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
976 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
977 total += (10000 + (2500 * plusses));
978 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
979 total += (10000 + (2500 * plusses));
983 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
984 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
985 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
986 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
987 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
988 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
989 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
990 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
991 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
992 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
993 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
994 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
995 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
996 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
997 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
998 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
999 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
1000 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
1001 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
1002 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
1003 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
1005 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
1006 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
1007 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
1008 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
1009 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
1010 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
1011 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
1012 total += (tmp_cost * count);
1014 if (have_flag(flgs, TR_SUST_STR)) total += 850;
1015 if (have_flag(flgs, TR_SUST_INT)) total += 850;
1016 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
1017 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
1018 if (have_flag(flgs, TR_SUST_CON)) total += 850;
1019 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
1020 if (have_flag(flgs, TR_RIDING)) total += 0;
1021 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1022 if (have_flag(flgs, TR_THROW)) total += 5000;
1023 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1024 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1028 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1029 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1030 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1031 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1032 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1033 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1034 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1035 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1036 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1037 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1038 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1039 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1040 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1041 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1042 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1043 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1044 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1045 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1046 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1047 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1048 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1049 total += (tmp_cost * count);
1051 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1052 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1053 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1054 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1055 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1056 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1057 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1058 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1059 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1060 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1061 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1062 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1063 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1064 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1065 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1066 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1067 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1068 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1069 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1070 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1071 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1072 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1073 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1074 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1075 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1076 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1077 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1078 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1079 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1080 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1081 if (have_flag(flgs, TR_REGEN)) total += 2500;
1082 if (have_flag(flgs, TR_WARNING)) total += 2000;
1083 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1084 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1085 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1086 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1087 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1088 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1089 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1090 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1091 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1092 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1093 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1094 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1095 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1096 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1097 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1098 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1099 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1100 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1101 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1102 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1103 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1104 if (have_flag(flgs, TR_TELEPORT))
1106 if (object_is_cursed(o_ptr))
1111 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1112 if (have_flag(flgs, TR_BLESSED)) total += 750;
1113 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1114 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1115 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1116 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1117 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1119 /* Also, give some extra for activatable powers... */
1120 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1122 const activation_type* const act_ptr = find_activation_info(o_ptr);
1124 total += act_ptr->value;
1133 * @brief オブジェクトの真の価格を算出する /
1134 * Return the value of the flags the object has...
1135 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1136 * @return オブジェクトの本価格
1138 * Return the "real" price of a "known" item, not including discounts\n
1140 * Wand and staffs get cost for each charge\n
1142 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1144 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1146 * Missiles are only worth 5 gold per bonus point, since they\n
1147 * usually appear in groups of 20, and we want the player to get\n
1148 * the same amount of cash for any "equivalent" item. Note that\n
1149 * missiles never have any of the "pval" flags, and in fact, they\n
1150 * only have a few of the available flags, primarily of the "slay"\n
1151 * and "brand" and "ignore" variety.\n
1153 * Armor with a negative armor bonus is worthless.\n
1154 * Weapons with negative hit+damage bonuses are worthless.\n
1156 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1158 s32b object_value_real(object_type *o_ptr)
1162 u32b flgs[TR_FLAG_SIZE];
1164 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1167 /* Hack -- "worthless" items */
1168 if (!k_info[o_ptr->k_idx].cost) return (0L);
1171 value = k_info[o_ptr->k_idx].cost;
1173 /* Extract some flags */
1174 object_flags(o_ptr, flgs);
1177 if (object_is_fixed_artifact(o_ptr))
1179 artifact_type *a_ptr = &a_info[o_ptr->name1];
1181 /* Hack -- "worthless" artifacts */
1182 if (!a_ptr->cost) return (0L);
1184 /* Hack -- Use the artifact cost instead */
1185 value = a_ptr->cost;
1186 value += flag_cost(o_ptr, o_ptr->pval);
1188 /* Don't add pval bonuses etc. */
1193 else if (object_is_ego(o_ptr))
1195 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1197 /* Hack -- "worthless" ego-items */
1198 if (!e_ptr->cost) return (0L);
1200 /* Hack -- Reward the ego-item with a bonus */
1201 value += e_ptr->cost;
1202 value += flag_cost(o_ptr, o_ptr->pval);
1210 for (i = 0; i < TR_FLAG_SIZE; i++)
1211 if (o_ptr->art_flags[i]) flag = TRUE;
1213 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1216 /* Analyze pval bonus for normal object */
1217 switch (o_ptr->tval)
1240 if (!o_ptr->pval) break;
1242 /* Hack -- Negative "pval" is always bad */
1243 if (o_ptr->pval < 0) return (0L);
1245 /* Give credit for stat bonuses */
1246 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1247 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1248 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1249 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1250 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1251 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1253 /* Give credit for stealth and searching */
1254 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1255 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1256 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1258 /* Give credit for infra-vision and tunneling */
1259 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1260 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1262 /* Give credit for extra attacks */
1263 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1265 /* Give credit for speed bonus */
1266 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1272 /* Analyze the item */
1273 switch (o_ptr->tval)
1278 /* Pay extra for charges, depending on standard number of
1279 * charges. Handle new-style wands correctly. -LM-
1281 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1288 /* Pay extra for charges, depending on standard number of
1291 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1301 /* Hack -- negative bonuses are bad */
1302 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1304 /* Give credit for bonuses */
1305 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1322 /* Hack -- negative armor bonus */
1323 if (o_ptr->to_a < 0) return (0L);
1325 /* Give credit for bonuses */
1326 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1339 /* Hack -- negative hit/damage bonuses */
1340 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1342 /* Factor in the bonuses */
1343 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1345 /* Hack -- Factor in extra damage dice and sides */
1346 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1347 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1358 /* Hack -- negative hit/damage bonuses */
1359 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1361 /* Factor in the bonuses */
1362 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1364 /* Hack -- Factor in extra damage dice and sides */
1365 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1366 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1372 /* Figurines, relative to monster level */
1375 int level = r_info[o_ptr->pval].level;
1376 if (level < 20) value = level*50L;
1377 else if (level < 30) value = 1000+(level-20)*150L;
1378 else if (level < 40) value = 2500+(level-30)*350L;
1379 else if (level < 50) value = 6000+(level-40)*800L;
1380 else value = 14000+(level-50)*2000L;
1386 if (!o_ptr->pval) value = 1000L;
1387 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1393 if (!o_ptr->pval) value = 0L;
1398 /* Worthless object */
1399 if (value < 0) return 0L;
1401 /* Return the value */
1407 * @brief オブジェクト価格算出のメインルーチン /
1408 * Return the price of an item including plusses (and charges)
1409 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1410 * @return オブジェクトの判明している現価格
1412 * This function returns the "value" of the given item (qty one)\n
1414 * Never notice "unknown" bonuses or properties, including "curses",\n
1415 * since that would give the player information he did not have.\n
1417 * Note that discounted items stay discounted forever, even if\n
1418 * the discount is "forgotten" by the player via memory loss.\n
1420 s32b object_value(object_type *o_ptr)
1425 /* Unknown items -- acquire a base value */
1426 if (object_is_known(o_ptr))
1428 /* Broken items -- worthless */
1429 if (object_is_broken(o_ptr)) return (0L);
1431 /* Cursed items -- worthless */
1432 if (object_is_cursed(o_ptr)) return (0L);
1434 /* Real value (see above) */
1435 value = object_value_real(o_ptr);
1438 /* Known items -- acquire the actual value */
1441 /* Hack -- Felt broken items */
1442 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1444 /* Hack -- Felt cursed items */
1445 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1447 /* Base value (see above) */
1448 value = object_value_base(o_ptr);
1452 /* Apply discount (if any) */
1453 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1456 /* Return the final value */
1463 * @brief 破壊可能なアイテムかを返す /
1464 * Determines whether an object can be destroyed, and makes fake inscription.
1465 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1466 * @return オブジェクトが破壊可能ならばTRUEを返す
1468 bool can_player_destroy_object(object_type *o_ptr)
1470 /* Artifacts cannot be destroyed */
1471 if (!object_is_artifact(o_ptr)) return TRUE;
1473 /* If object is unidentified, makes fake inscription */
1474 if (!object_is_known(o_ptr))
1476 byte feel = FEEL_SPECIAL;
1478 /* Hack -- Handle icky artifacts */
1479 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1481 /* Hack -- inscribe the artifact */
1482 o_ptr->feeling = feel;
1484 /* We have "felt" it (again) */
1485 o_ptr->ident |= (IDENT_SENSE);
1487 /* Combine the pack */
1488 p_ptr->notice |= (PN_COMBINE);
1491 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1497 /* Identified artifact -- Nothing to do */
1503 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1504 * Distribute charges of rods or wands.
1505 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1506 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1507 * @param amt 分割したい回数量 number of items that are transfered
1510 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1511 * charges need to be allocated between the two stacks. If all the items\n
1512 * are being dropped, it makes for a neater message to leave the original\n
1513 * stack's pval alone. -LM-\n
1515 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1517 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1519 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1520 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1522 /* Hack -- Rods also need to have their timeouts distributed. The
1523 * dropped stack will accept all time remaining to charge up to its
1526 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1528 if (q_ptr->pval > o_ptr->timeout)
1529 q_ptr->timeout = o_ptr->timeout;
1531 q_ptr->timeout = q_ptr->pval;
1533 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1539 * @brief 魔法棒やロッドの使用回数を減らす /
1540 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1541 * @param amt 減らしたい回数量 number of items that are transfered
1544 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1545 * charges of the stack needs to be reduced, unless all the items are\n
1546 * being destroyed. -LM-\n
1548 void reduce_charges(object_type *o_ptr, int amt)
1550 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1551 (amt < o_ptr->number))
1553 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1558 * Determine if an item can "absorb" a second item
1560 * See "object_absorb()" for the actual "absorption" code.
1562 * If permitted, we allow staffs (if they are known to have equal charges
1563 * and both are either known or confirmed empty) and wands (if both are
1564 * either known or confirmed empty) and rods (in all cases) to combine.
1565 * Staffs will unstack (if necessary) when they are used, but wands and
1566 * rods will only unstack if one is dropped. -LM-
1568 * If permitted, we allow weapons/armor to stack, if fully "known".
1570 * Missiles will combine if both stacks have the same "known" status.
1571 * This is done to make unidentified stacks of missiles useful.
1573 * Food, potions, scrolls, and "easy know" items always stack.
1575 * Chests, and activatable items, never stack (for various reasons).
1579 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1581 #define MAX_STACK_SIZE 99
1585 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1586 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1587 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1588 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1589 * @return 重ね合わせ可能なアイテム数
1591 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1595 /* Default maximum number of stack */
1596 int max_num = MAX_STACK_SIZE;
1598 /* Require identical object types */
1599 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1602 /* Analyze the items */
1603 switch (o_ptr->tval)
1605 /* Chests and Statues*/
1616 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1617 if (o_ptr->pval != j_ptr->pval) return 0;
1621 /* Figurines and Corpses*/
1626 if (o_ptr->pval != j_ptr->pval) return 0;
1632 /* Food and Potions and Scrolls */
1644 /* Require either knowledge or known empty for both staffs. */
1645 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1646 !object_is_known(o_ptr)) ||
1647 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1648 !object_is_known(j_ptr))) return 0;
1650 /* Require identical charges, since staffs are bulky. */
1651 if (o_ptr->pval != j_ptr->pval) return 0;
1660 /* Require either knowledge or known empty for both wands. */
1661 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1662 !object_is_known(o_ptr)) ||
1663 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1664 !object_is_known(j_ptr))) return 0;
1666 /* Wand charges combine in O&ZAngband. */
1672 /* Staffs and Wands and Rods */
1675 /* Prevent overflaw of timeout */
1676 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1682 /* Weapons and Armor */
1698 /* Rings, Amulets, Lites */
1704 /* Require full knowledge of both items */
1705 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1715 /* Require identical knowledge of both items */
1716 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1717 if (o_ptr->feeling != j_ptr->feeling) return 0;
1719 /* Require identical "bonuses" */
1720 if (o_ptr->to_h != j_ptr->to_h) return 0;
1721 if (o_ptr->to_d != j_ptr->to_d) return 0;
1722 if (o_ptr->to_a != j_ptr->to_a) return 0;
1724 /* Require identical "pval" code */
1725 if (o_ptr->pval != j_ptr->pval) return 0;
1727 /* Artifacts never stack */
1728 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1730 /* Require identical "ego-item" names */
1731 if (o_ptr->name2 != j_ptr->name2) return 0;
1733 /* Require identical added essence */
1734 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1735 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1737 /* Hack -- Never stack "powerful" items */
1738 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1740 /* Hack -- Never stack recharging items */
1741 if (o_ptr->timeout || j_ptr->timeout) return 0;
1743 /* Require identical "values" */
1744 if (o_ptr->ac != j_ptr->ac) return 0;
1745 if (o_ptr->dd != j_ptr->dd) return 0;
1746 if (o_ptr->ds != j_ptr->ds) return 0;
1755 /* Require knowledge */
1756 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1764 /* Hack -- Identical art_flags! */
1765 for (i = 0; i < TR_FLAG_SIZE; i++)
1766 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1768 /* Hack -- Require identical "cursed" status */
1769 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1771 /* Hack -- Require identical "broken" status */
1772 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1775 /* Hack -- require semi-matching "inscriptions" */
1776 if (o_ptr->inscription && j_ptr->inscription &&
1777 (o_ptr->inscription != j_ptr->inscription))
1780 /* Hack -- normally require matching "inscriptions" */
1781 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1783 /* Hack -- normally require matching "discounts" */
1784 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1787 /* They match, so they must be similar */
1792 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1793 * Determine if an item can absorb a second item.
1794 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1795 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1796 * @return 重ね合わせ可能ならばTRUEを返す。
1798 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1800 int total = o_ptr->number + j_ptr->number;
1803 /* Are these objects similar? */
1804 max_num = object_similar_part(o_ptr, j_ptr);
1806 /* Return if not similar */
1807 if (!max_num) return FALSE;
1809 /* Maximal "stacking" limit */
1810 if (total > max_num) return (0);
1813 /* They match, so they must be similar */
1819 * @brief 両オブジェクトをスロットに重ね合わせる。
1820 * Allow one item to "absorb" another, assuming they are similar
1821 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1822 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1825 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1827 int max_num = object_similar_part(o_ptr, j_ptr);
1828 int total = o_ptr->number + j_ptr->number;
1829 int diff = (total > max_num) ? total - max_num : 0;
1831 /* Combine quantity, lose excess items */
1832 o_ptr->number = (total > max_num) ? max_num : total;
1834 /* Hack -- blend "known" status */
1835 if (object_is_known(j_ptr)) object_known(o_ptr);
1837 /* Hack -- clear "storebought" if only one has it */
1838 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1839 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1841 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1842 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1845 /* Hack -- blend "mental" status */
1846 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1848 /* Hack -- blend "inscriptions" */
1849 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1851 /* Hack -- blend "feelings" */
1852 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1854 /* Hack -- could average discounts XXX XXX XXX */
1855 /* Hack -- save largest discount XXX XXX XXX */
1856 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1858 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1859 if (o_ptr->tval == TV_ROD)
1861 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1862 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1865 /* Hack -- if wands are stacking, combine the charges. -LM- */
1866 if (o_ptr->tval == TV_WAND)
1868 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1874 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1875 * Find the index of the object_kind with the given tval and sval
1876 * @param tval 検索したいベースアイテムのtval
1877 * @param sval 検索したいベースアイテムのsval
1880 IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
1887 for (k = 1; k < max_k_idx; k++)
1889 object_kind *k_ptr = &k_info[k];
1891 /* Require correct tval */
1892 if (k_ptr->tval != tval) continue;
1895 if (k_ptr->sval == sval) return (k);
1897 /* Ignore illegal items */
1898 if (sval != SV_ANY) continue;
1900 /* Apply the randomizer */
1901 if (!one_in_(++num)) continue;
1903 /* Use this value */
1907 /* Return this choice */
1915 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1925 * @brief オブジェクトを初期化する
1926 * Wipe an object clean.
1927 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1930 void object_wipe(object_type *o_ptr)
1932 /* Wipe the structure */
1933 (void)WIPE(o_ptr, object_type);
1938 * @brief オブジェクトを複製する
1939 * Wipe an object clean.
1940 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1941 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1944 void object_copy(object_type *o_ptr, object_type *j_ptr)
1946 /* Copy the structure */
1947 (void)COPY(o_ptr, j_ptr, object_type);
1952 * @brief オブジェクト構造体にベースアイテムを作成する
1953 * Prepare an object based on an object kind.
1954 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1955 * @param k_idx 新たに作成したいベースアイテム情報のID
1958 void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
1960 object_kind *k_ptr = &k_info[k_idx];
1962 /* Clear the record */
1965 /* Save the kind index */
1966 o_ptr->k_idx = k_idx;
1968 /* Efficiency -- tval/sval */
1969 o_ptr->tval = k_ptr->tval;
1970 o_ptr->sval = k_ptr->sval;
1972 /* Default "pval" */
1973 o_ptr->pval = k_ptr->pval;
1975 /* Default number */
1978 /* Default weight */
1979 o_ptr->weight = k_ptr->weight;
1982 o_ptr->to_h = k_ptr->to_h;
1983 o_ptr->to_d = k_ptr->to_d;
1984 o_ptr->to_a = k_ptr->to_a;
1987 o_ptr->ac = k_ptr->ac;
1988 o_ptr->dd = k_ptr->dd;
1989 o_ptr->ds = k_ptr->ds;
1991 /* Default activation */
1992 if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx;
1994 /* Hack -- worthless items are always "broken" */
1995 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1997 /* Hack -- cursed items are always "cursed" */
1998 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1999 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2000 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
2001 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
2002 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
2003 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
2008 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
2009 * Help determine an "enchantment bonus" for an object.
2010 * @param max ボーナス値の限度
2011 * @param level ボーナス値に加味する基準生成階
2012 * @return 算出されたボーナス値
2014 * To avoid floating point but still provide a smooth distribution of bonuses,\n
2015 * we simply round the results of division in such a way as to "average" the\n
2016 * correct floating point value.\n
2018 * This function has been changed. It uses "randnor()" to choose values from\n
2019 * a normal distribution, whose mean moves from zero towards the max as the\n
2020 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2021 * and whose values are forced to lie between zero and the max, inclusive.\n
2023 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2024 * rare to get the "full" enchantment on an object, even a deep levels.\n
2026 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2028 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2030 * N 0 1 2 3 4 5 6 7 8 9 10\n
2031 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2032 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2033 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2034 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2035 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2036 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2037 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2038 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2039 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2040 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2041 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2042 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2043 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2044 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2045 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2046 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2047 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2048 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2050 int m_bonus(int max, DEPTH level)
2052 int bonus, stand, extra, value;
2055 /* Paranoia -- enforce maximal "level" */
2056 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2059 /* The "bonus" moves towards the max */
2060 bonus = ((max * level) / MAX_DEPTH);
2062 /* Hack -- determine fraction of error */
2063 extra = ((max * level) % MAX_DEPTH);
2065 /* Hack -- simulate floating point computations */
2066 if (randint0(MAX_DEPTH) < extra) bonus++;
2069 /* The "stand" is equal to one quarter of the max */
2072 /* Hack -- determine fraction of error */
2075 /* Hack -- simulate floating point computations */
2076 if (randint0(4) < extra) stand++;
2079 /* Choose an "interesting" value */
2080 value = randnor(bonus, stand);
2082 /* Enforce the minimum value */
2083 if (value < 0) return (0);
2085 /* Enforce the maximum value */
2086 if (value > max) return (max);
2094 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2095 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2098 static void object_mention(object_type *o_ptr)
2100 char o_name[MAX_NLEN];
2102 object_aware(o_ptr);
2103 object_known(o_ptr);
2105 /* Mark the item as fully known */
2106 o_ptr->ident |= (IDENT_MENTAL);
2109 object_desc(o_name, o_ptr, 0);
2110 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2114 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2115 * Mega-Hack -- Attempt to create one of the "Special Objects"
2116 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2117 * @return 生成に成功したらTRUEを返す。
2119 * We are only called from "make_object()", and we assume that\n
2120 * "apply_magic()" is called immediately after we return.\n
2122 * Note -- see "make_artifact()" and "apply_magic()"\n
2124 static bool make_artifact_special(object_type *o_ptr)
2129 /*! @note 地上ではキャンセルする / No artifacts in the town */
2130 if (!dun_level) return (FALSE);
2132 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2133 if (get_obj_num_hook) return (FALSE);
2135 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2136 for (i = 0; i < max_a_idx; i++)
2138 artifact_type *a_ptr = &a_info[i];
2140 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2141 if (!a_ptr->name) continue;
2143 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2144 if (a_ptr->cur_num) continue;
2145 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2146 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2148 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2149 * XXX XXX Enforce minimum "depth" (loosely) */
2150 if (a_ptr->level > object_level)
2152 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2153 int d = (a_ptr->level - object_level) * 2;
2154 if (!one_in_(d)) continue;
2157 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2158 if (!one_in_(a_ptr->rarity)) continue;
2160 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2161 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2162 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2163 if (k_info[k_idx].level > object_level)
2165 int d = (k_info[k_idx].level - object_level) * 5;
2166 if (!one_in_(d)) continue;
2169 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2170 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2171 object_prep(o_ptr, k_idx);
2174 random_artifact_resistance(o_ptr, a_ptr);
2178 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2184 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2185 * Mega-Hack -- Attempt to create one of the "Special Objects"
2186 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2187 * @return 生成に成功したらTRUEを返す。
2189 * Attempt to change an object into an artifact\n
2190 * This routine should only be called by "apply_magic()"\n
2191 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2193 static bool make_artifact(object_type *o_ptr)
2198 /* No artifacts in the town */
2199 if (!dun_level) return (FALSE);
2201 /* Paranoia -- no "plural" artifacts */
2202 if (o_ptr->number != 1) return (FALSE);
2204 /* Check the artifact list (skip the "specials") */
2205 for (i = 0; i < max_a_idx; i++)
2207 artifact_type *a_ptr = &a_info[i];
2209 /* Skip "empty" items */
2210 if (!a_ptr->name) continue;
2212 /* Cannot make an artifact twice */
2213 if (a_ptr->cur_num) continue;
2215 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2217 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2219 /* Must have the correct fields */
2220 if (a_ptr->tval != o_ptr->tval) continue;
2221 if (a_ptr->sval != o_ptr->sval) continue;
2223 /* XXX XXX Enforce minimum "depth" (loosely) */
2224 if (a_ptr->level > dun_level)
2226 /* Acquire the "out-of-depth factor" */
2227 int d = (a_ptr->level - dun_level) * 2;
2229 /* Roll for out-of-depth creation */
2230 if (!one_in_(d)) continue;
2233 /* We must make the "rarity roll" */
2234 if (!one_in_(a_ptr->rarity)) continue;
2236 /* Hack -- mark the item as an artifact */
2239 /* Hack: Some artifacts get random extra powers */
2240 random_artifact_resistance(o_ptr, a_ptr);
2252 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2253 * Choose random ego type
2254 * @param slot 取得したいエゴの装備部位
2255 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2256 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2258 static byte get_random_ego(byte slot, bool good)
2261 ego_item_type *e_ptr;
2265 for (i = 1; i < max_e_idx; i++)
2269 if (e_ptr->slot == slot
2270 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2273 total += (255 / e_ptr->rarity);
2277 value = randint1(total);
2279 for (i = 1; i < max_e_idx; i++)
2283 if (e_ptr->slot == slot
2284 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2287 value -= (255 / e_ptr->rarity);
2288 if (value <= 0L) break;
2296 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2297 * Apply magic to an item known to be a "weapon"
2298 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2299 * @param level 生成基準階
2300 * @param power 生成ランク
2303 * Hack -- note special base damage dice boosting\n
2304 * Hack -- note special processing for weapon/digger\n
2306 static void a_m_aux_1(object_type *o_ptr, DEPTH level, int power)
2308 HIT_PROB tohit1 = randint1(5) + (HIT_PROB)m_bonus(5, level);
2309 HIT_POINT todam1 = randint1(5) + (HIT_POINT)m_bonus(5, level);
2311 HIT_PROB tohit2 = (HIT_PROB)m_bonus(10, level);
2312 HIT_POINT todam2 = (HIT_POINT)m_bonus(10, level);
2314 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2316 tohit2 = (tohit2+1)/2;
2317 todam2 = (todam2+1)/2;
2324 o_ptr->to_h += tohit1;
2325 o_ptr->to_d += todam1;
2331 o_ptr->to_h += tohit2;
2332 o_ptr->to_d += todam2;
2340 o_ptr->to_h -= tohit1;
2341 o_ptr->to_d -= todam1;
2346 /* Penalize again */
2347 o_ptr->to_h -= tohit2;
2348 o_ptr->to_d -= todam2;
2351 /* Cursed (if "bad") */
2352 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2355 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2358 switch (o_ptr->tval)
2365 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2366 create_artifact(o_ptr, FALSE);
2368 /* Special Ego-item */
2369 o_ptr->name2 = EGO_DIGGING;
2373 else if (power < -1)
2375 /* Hack -- Horrible digging bonus */
2376 o_ptr->pval = 0 - (5 + randint1(5));
2382 /* Hack -- Reverse digging bonus */
2383 o_ptr->pval = 0 - (o_ptr->pval);
2397 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2399 create_artifact(o_ptr, FALSE);
2404 /* Roll for an ego-item */
2405 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2406 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2408 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2410 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2415 switch (o_ptr->name2)
2418 if (one_in_(4) && (level > 40))
2419 add_flag(o_ptr->art_flags, TR_BLOWS);
2423 add_flag(o_ptr->art_flags, TR_RES_POIS);
2425 add_flag(o_ptr->art_flags, TR_WARNING);
2427 case EGO_KILL_DRAGON:
2429 add_flag(o_ptr->art_flags, TR_RES_POIS);
2433 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2435 case EGO_SLAYING_WEAPON:
2436 if (one_in_(3)) /* double damage */
2444 while (one_in_(o_ptr->dd));
2450 while (one_in_(o_ptr->ds));
2455 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2457 if (o_ptr->tval == TV_SWORD && one_in_(3))
2459 add_flag(o_ptr->art_flags, TR_VORPAL);
2464 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2470 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2472 add_flag(o_ptr->art_flags, TR_DEX);
2474 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2477 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, level) + 1;
2479 case EGO_EARTHQUAKES:
2480 if (one_in_(3) && (level > 60))
2481 add_flag(o_ptr->art_flags, TR_BLOWS);
2483 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, level);
2487 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2491 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2493 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2495 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2496 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2499 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2500 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2501 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2502 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2506 if (!o_ptr->art_name)
2508 /* Hack -- Super-charge the damage dice */
2509 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2511 /* Hack -- Lower the damage dice */
2512 if (o_ptr->dd > 9) o_ptr->dd = 9;
2517 else if (power < -1)
2519 /* Roll for ego-item */
2520 if (randint0(MAX_DEPTH) < level)
2524 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2525 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2531 switch (o_ptr->name2)
2534 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2535 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2537 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2538 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2539 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2540 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2541 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2542 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2556 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2558 create_artifact(o_ptr, FALSE);
2561 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2575 if (power > 2) /* power > 2 is debug only */
2577 create_artifact(o_ptr, FALSE);
2581 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2583 switch (o_ptr->name2)
2585 case EGO_SLAYING_BOLT:
2590 /* Hack -- super-charge the damage dice */
2591 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2593 /* Hack -- restrict the damage dice */
2594 if (o_ptr->dd > 9) o_ptr->dd = 9;
2598 else if (power < -1)
2600 /* Roll for ego-item */
2601 if (randint0(MAX_DEPTH) < level)
2603 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2613 * @brief ドラゴン装備にランダムな耐性を与える
2614 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2617 static void dragon_resist(object_type * o_ptr)
2622 one_dragon_ele_resistance(o_ptr);
2624 one_high_resistance(o_ptr);
2630 * @brief オブジェクトにランダムな強いESPを与える
2631 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2634 static bool add_esp_strong(object_type *o_ptr)
2636 bool nonliv = FALSE;
2638 switch (randint1(3))
2640 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2641 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2642 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2649 * @brief オブジェクトにランダムな弱いESPを与える
2650 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2651 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2654 static void add_esp_weak(object_type *o_ptr, bool extra)
2657 u32b weak_esp_list[] = {
2669 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2670 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2672 /* Add unduplicated weak esp flags randomly */
2673 for (i = 0; i < add_count; ++ i)
2675 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2677 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2678 weak_esp_list[choice] = weak_esp_list[i];
2684 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2685 * Apply magic to an item known to be "armor"
2686 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2687 * @param level 生成基準階
2688 * @param power 生成ランク
2691 * Hack -- note special processing for crown/helm\n
2692 * Hack -- note special processing for robe of permanence\n
2694 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2696 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
2697 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
2703 o_ptr->to_a += toac1;
2709 o_ptr->to_a += toac2;
2717 o_ptr->to_a -= toac1;
2722 /* Penalize again */
2723 o_ptr->to_a -= toac2;
2726 /* Cursed (if "bad") */
2727 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2732 switch (o_ptr->tval)
2736 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2737 create_artifact(o_ptr, FALSE);
2747 /* Hack -- Try for "Robes of the Magi" */
2748 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2749 (o_ptr->sval == SV_ROBE) &&
2750 (randint0(100) < 15))
2754 o_ptr->name2 = EGO_YOIYAMI;
2755 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2756 o_ptr->sval = SV_YOIYAMI_ROBE;
2762 o_ptr->name2 = EGO_PERMANENCE;
2767 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2769 create_artifact(o_ptr, FALSE);
2775 bool okay_flag = TRUE;
2777 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2779 switch (o_ptr->name2)
2782 if (o_ptr->tval != TV_HARD_ARMOR)
2788 if (o_ptr->tval != TV_SOFT_ARMOR)
2797 if (okay_flag) break;
2799 switch (o_ptr->name2)
2801 case EGO_RESISTANCE:
2803 add_flag(o_ptr->art_flags, TR_RES_POIS);
2806 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2807 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2811 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2813 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2815 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2816 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2818 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2819 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2820 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2821 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2822 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2823 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2824 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2825 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2828 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2829 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2830 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2831 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2832 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2833 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2846 if (o_ptr->sval == SV_DRAGON_SHIELD)
2848 dragon_resist(o_ptr);
2849 if (!one_in_(3)) break;
2855 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2857 create_artifact(o_ptr, FALSE);
2863 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2864 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2865 && o_ptr->name2 == EGO_S_DWARVEN)
2872 switch (o_ptr->name2)
2875 if (!one_in_(3)) one_high_resistance(o_ptr);
2876 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2878 case EGO_REFLECTION:
2879 if (o_ptr->sval == SV_MIRROR_SHIELD)
2884 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2885 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2894 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2896 dragon_resist(o_ptr);
2897 if (!one_in_(3)) break;
2901 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2903 create_artifact(o_ptr, FALSE);
2906 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2910 else if (power < -1)
2912 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2920 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2922 dragon_resist(o_ptr);
2923 if (!one_in_(3)) break;
2928 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2930 create_artifact(o_ptr, FALSE);
2933 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2935 switch (o_ptr->name2)
2937 case EGO_SLOW_DESCENT:
2940 one_high_resistance(o_ptr);
2946 else if (power < -1)
2948 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2959 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2961 create_artifact(o_ptr, FALSE);
2966 bool ok_flag = TRUE;
2967 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2969 switch (o_ptr->name2)
2972 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2973 else add_esp_weak(o_ptr, FALSE);
2977 case EGO_REGENERATION:
2978 case EGO_LORDLINESS:
2984 if (one_in_(2)) add_esp_strong(o_ptr);
2985 else add_esp_weak(o_ptr, FALSE);
2988 default:/* not existing crown (wisdom,lite, etc...) */
2992 break; /* while (1) */
2998 else if (power < -1)
3002 bool ok_flag = TRUE;
3003 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3005 switch (o_ptr->name2)
3007 case EGO_ANCIENT_CURSE:
3008 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3009 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3010 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3011 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3012 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3013 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3017 break; /* while (1) */
3026 if (o_ptr->sval == SV_DRAGON_HELM)
3028 dragon_resist(o_ptr);
3029 if (!one_in_(3)) break;
3035 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3037 create_artifact(o_ptr, FALSE);
3042 bool ok_flag = TRUE;
3043 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3045 switch (o_ptr->name2)
3047 case EGO_BRILLIANCE:
3049 case EGO_INFRAVISION:
3050 case EGO_H_PROTECTION:
3055 if (one_in_(2)) add_esp_strong(o_ptr);
3056 else add_esp_weak(o_ptr, FALSE);
3060 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3061 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3064 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3066 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3068 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3069 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3071 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3072 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3073 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3074 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3075 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3076 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3077 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3078 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3080 default:/* not existing helm (Magi, Might, etc...)*/
3084 break; /* while (1) */
3089 else if (power < -1)
3093 bool ok_flag = TRUE;
3094 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3096 switch (o_ptr->name2)
3098 case EGO_ANCIENT_CURSE:
3102 break; /* while (1) */
3113 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3115 create_artifact(o_ptr, FALSE);
3118 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3120 switch (o_ptr->name2)
3129 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3130 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3131 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3132 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3139 else if (power < -1)
3141 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3152 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3153 * Apply magic to an item known to be a "ring" or "amulet"
3154 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3155 * @param level 生成基準階
3156 * @param power 生成ランク
3159 * Hack -- note special "pval boost" code for ring of speed\n
3160 * Hack -- note that some items must be cursed (or blessed)\n
3162 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3164 /* Apply magic (good or bad) according to type */
3165 switch (o_ptr->tval)
3170 switch (o_ptr->sval)
3172 case SV_RING_ATTACKS:
3175 o_ptr->pval = (PARAMETER_VALUE)m_bonus(2, level);
3176 if (one_in_(15)) o_ptr->pval++;
3177 if (o_ptr->pval < 1) o_ptr->pval = 1;
3183 o_ptr->ident |= (IDENT_BROKEN);
3186 o_ptr->curse_flags |= TRC_CURSED;
3189 o_ptr->pval = 0 - (o_ptr->pval);
3200 /* Strength, Constitution, Dexterity, Intelligence */
3206 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3212 o_ptr->ident |= (IDENT_BROKEN);
3215 o_ptr->curse_flags |= TRC_CURSED;
3218 o_ptr->pval = 0 - (o_ptr->pval);
3224 /* Ring of Speed! */
3227 /* Base speed (1 to 10) */
3228 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3230 /* Super-charge the ring */
3231 while (randint0(100) < 50) o_ptr->pval++;
3237 o_ptr->ident |= (IDENT_BROKEN);
3240 o_ptr->curse_flags |= TRC_CURSED;
3243 o_ptr->pval = 0 - (o_ptr->pval);
3251 case SV_RING_LORDLY:
3255 one_lordly_high_resistance(o_ptr);
3259 /* Bonus to armor class */
3260 o_ptr->to_a = 10 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3264 case SV_RING_WARNING:
3266 if (one_in_(3)) one_low_esp(o_ptr);
3271 case SV_RING_SEARCHING:
3273 /* Bonus to searching */
3274 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3280 o_ptr->ident |= (IDENT_BROKEN);
3283 o_ptr->curse_flags |= TRC_CURSED;
3286 o_ptr->pval = 0 - (o_ptr->pval);
3292 /* Flames, Acid, Ice */
3293 case SV_RING_FLAMES:
3298 /* Bonus to armor class */
3299 o_ptr->to_a = 5 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3303 /* Weakness, Stupidity */
3304 case SV_RING_WEAKNESS:
3305 case SV_RING_STUPIDITY:
3308 o_ptr->ident |= (IDENT_BROKEN);
3311 o_ptr->curse_flags |= TRC_CURSED;
3314 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3315 if (power > 0) power = 0 - power;
3320 /* WOE, Stupidity */
3324 o_ptr->ident |= (IDENT_BROKEN);
3327 o_ptr->curse_flags |= TRC_CURSED;
3330 o_ptr->to_a = 0 - (5 + (ARMOUR_CLASS)m_bonus(10, level));
3331 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3332 if (power > 0) power = 0 - power;
3337 /* Ring of damage */
3338 case SV_RING_DAMAGE:
3340 /* Bonus to damage */
3341 o_ptr->to_d = 1 + randint1(5) + (HIT_POINT)m_bonus(16, level);
3347 o_ptr->ident |= (IDENT_BROKEN);
3350 o_ptr->curse_flags |= TRC_CURSED;
3353 o_ptr->to_d = 0 - o_ptr->to_d;
3359 /* Ring of Accuracy */
3360 case SV_RING_ACCURACY:
3363 o_ptr->to_h = 1 + randint1(5) + (HIT_PROB)m_bonus(16, level);
3369 o_ptr->ident |= (IDENT_BROKEN);
3372 o_ptr->curse_flags |= TRC_CURSED;
3375 o_ptr->to_h = 0 - o_ptr->to_h;
3381 /* Ring of Protection */
3382 case SV_RING_PROTECTION:
3384 /* Bonus to armor class */
3385 o_ptr->to_a = 5 + randint1(8) + (ARMOUR_CLASS)m_bonus(10, level);
3391 o_ptr->ident |= (IDENT_BROKEN);
3394 o_ptr->curse_flags |= TRC_CURSED;
3397 o_ptr->to_a = 0 - o_ptr->to_a;
3403 /* Ring of Slaying */
3404 case SV_RING_SLAYING:
3406 /* Bonus to damage and to hit */
3407 o_ptr->to_d = randint1(5) + (HIT_POINT)m_bonus(12, level);
3408 o_ptr->to_h = randint1(5) + (HIT_PROB)m_bonus(12, level);
3414 o_ptr->ident |= (IDENT_BROKEN);
3417 o_ptr->curse_flags |= TRC_CURSED;
3419 /* Reverse bonuses */
3420 o_ptr->to_h = 0 - o_ptr->to_h;
3421 o_ptr->to_d = 0 - o_ptr->to_d;
3427 case SV_RING_MUSCLE:
3429 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(3, level);
3430 if (one_in_(4)) o_ptr->pval++;
3436 o_ptr->ident |= (IDENT_BROKEN);
3439 o_ptr->curse_flags |= TRC_CURSED;
3441 /* Reverse bonuses */
3442 o_ptr->pval = 0 - o_ptr->pval;
3447 case SV_RING_AGGRAVATION:
3450 o_ptr->ident |= (IDENT_BROKEN);
3453 o_ptr->curse_flags |= TRC_CURSED;
3455 if (power > 0) power = 0 - power;
3459 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3460 || (power > 2)) /* power > 2 is debug only */
3462 o_ptr->pval = MIN(o_ptr->pval, 4);
3463 /* Randart amulet */
3464 create_artifact(o_ptr, FALSE);
3466 else if ((power == 2) && one_in_(2))
3468 while(!o_ptr->name2)
3470 int tmp = m_bonus(10, level);
3471 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3472 switch(randint1(28))
3475 o_ptr->name2 = EGO_RING_THROW;
3478 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3479 o_ptr->name2 = EGO_RING_REGEN;
3482 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3483 o_ptr->name2 = EGO_RING_LITE;
3486 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3487 o_ptr->name2 = EGO_RING_TELEPORT;
3490 if (o_ptr->to_h) break;
3491 o_ptr->name2 = EGO_RING_TO_H;
3494 if (o_ptr->to_d) break;
3495 o_ptr->name2 = EGO_RING_TO_D;
3498 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3499 o_ptr->name2 = EGO_RING_SLAY;
3502 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3503 o_ptr->name2 = EGO_RING_WIZARD;
3506 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3507 o_ptr->name2 = EGO_RING_HERO;
3510 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3511 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3512 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3513 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3516 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3517 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;
3518 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3519 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3520 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3523 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3524 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;
3525 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3526 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3527 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3530 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3531 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;
3532 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3533 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3536 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3537 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;
3538 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3539 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3541 case 21: case 22: case 23: case 24: case 25: case 26:
3542 switch (o_ptr->sval)
3545 if (!one_in_(3)) break;
3546 o_ptr->name2 = EGO_RING_D_SPEED;
3548 case SV_RING_DAMAGE:
3549 case SV_RING_ACCURACY:
3550 case SV_RING_SLAYING:
3551 if (one_in_(2)) break;
3552 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3555 o_ptr->name2 = EGO_RING_BERSERKER;
3556 o_ptr->to_h -= 2+randint1(4);
3557 o_ptr->to_d += 2+randint1(4);
3560 case SV_RING_PROTECTION:
3561 o_ptr->name2 = EGO_RING_SUPER_AC;
3562 o_ptr->to_a += 7 + m_bonus(5, level);
3564 case SV_RING_RES_FEAR:
3565 o_ptr->name2 = EGO_RING_HERO;
3568 if (one_in_(2)) break;
3569 o_ptr->name2 = EGO_RING_HUNTER;
3571 case SV_RING_SEARCHING:
3572 o_ptr->name2 = EGO_RING_STEALTH;
3574 case SV_RING_TELEPORTATION:
3575 o_ptr->name2 = EGO_RING_TELE_AWAY;
3577 case SV_RING_RES_BLINDNESS:
3579 o_ptr->name2 = EGO_RING_RES_LITE;
3581 o_ptr->name2 = EGO_RING_RES_DARK;
3583 case SV_RING_LORDLY:
3584 if (!one_in_(20)) break;
3585 one_lordly_high_resistance(o_ptr);
3586 one_lordly_high_resistance(o_ptr);
3587 o_ptr->name2 = EGO_RING_TRUE;
3589 case SV_RING_SUSTAIN:
3590 if (!one_in_(4)) break;
3591 o_ptr->name2 = EGO_RING_RES_TIME;
3593 case SV_RING_FLAMES:
3594 if (!one_in_(2)) break;
3595 o_ptr->name2 = EGO_RING_DRAGON_F;
3598 if (!one_in_(2)) break;
3599 o_ptr->name2 = EGO_RING_DRAGON_C;
3601 case SV_RING_WARNING:
3602 if (!one_in_(2)) break;
3603 o_ptr->name2 = EGO_RING_M_DETECT;
3612 o_ptr->curse_flags = 0L;
3614 else if ((power == -2) && one_in_(2))
3616 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3617 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3618 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3619 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3620 o_ptr->art_flags[0] = 0;
3621 o_ptr->art_flags[1] = 0;
3622 while(!o_ptr->name2)
3624 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3628 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3629 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3632 o_ptr->name2 = EGO_RING_NO_MELEE;
3635 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3636 o_ptr->name2 = EGO_RING_AGGRAVATE;
3639 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3640 o_ptr->name2 = EGO_RING_TY_CURSE;
3643 o_ptr->name2 = EGO_RING_ALBINO;
3648 o_ptr->ident |= (IDENT_BROKEN);
3651 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3659 switch (o_ptr->sval)
3661 /* Amulet of wisdom/charisma */
3662 case SV_AMULET_INTELLIGENCE:
3663 case SV_AMULET_WISDOM:
3664 case SV_AMULET_CHARISMA:
3666 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3672 o_ptr->ident |= (IDENT_BROKEN);
3675 o_ptr->curse_flags |= (TRC_CURSED);
3677 /* Reverse bonuses */
3678 o_ptr->pval = 0 - o_ptr->pval;
3684 /* Amulet of brilliance */
3685 case SV_AMULET_BRILLIANCE:
3687 o_ptr->pval = 1 + m_bonus(3, level);
3688 if (one_in_(4)) o_ptr->pval++;
3694 o_ptr->ident |= (IDENT_BROKEN);
3697 o_ptr->curse_flags |= (TRC_CURSED);
3699 /* Reverse bonuses */
3700 o_ptr->pval = 0 - o_ptr->pval;
3706 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3710 o_ptr->curse_flags |= (TRC_CURSED);
3715 case SV_AMULET_RESISTANCE:
3717 if (one_in_(5)) one_high_resistance(o_ptr);
3718 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3722 /* Amulet of searching */
3723 case SV_AMULET_SEARCHING:
3725 o_ptr->pval = randint1(2) + (PARAMETER_VALUE)m_bonus(4, level);
3731 o_ptr->ident |= (IDENT_BROKEN);
3734 o_ptr->curse_flags |= (TRC_CURSED);
3736 /* Reverse bonuses */
3737 o_ptr->pval = 0 - (o_ptr->pval);
3743 /* Amulet of the Magi -- never cursed */
3744 case SV_AMULET_THE_MAGI:
3746 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3747 o_ptr->to_a = randint1(5) + (ARMOUR_CLASS)m_bonus(5, level);
3749 /* gain one low ESP */
3750 add_esp_weak(o_ptr, FALSE);
3755 /* Amulet of Doom -- always cursed */
3756 case SV_AMULET_DOOM:
3759 o_ptr->ident |= (IDENT_BROKEN);
3762 o_ptr->curse_flags |= (TRC_CURSED);
3765 o_ptr->pval = 0 - (randint1(5) + (PARAMETER_VALUE)m_bonus(5, level));
3766 o_ptr->to_a = 0 - (randint1(5) + (ARMOUR_CLASS)m_bonus(5, level));
3767 if (power > 0) power = 0 - power;
3772 case SV_AMULET_MAGIC_MASTERY:
3774 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(4, level);
3780 o_ptr->ident |= (IDENT_BROKEN);
3783 o_ptr->curse_flags |= (TRC_CURSED);
3785 /* Reverse bonuses */
3786 o_ptr->pval = 0 - o_ptr->pval;
3792 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3793 || (power > 2)) /* power > 2 is debug only */
3795 o_ptr->pval = MIN(o_ptr->pval, 4);
3796 /* Randart amulet */
3797 create_artifact(o_ptr, FALSE);
3799 else if ((power == 2) && one_in_(2))
3801 while(!o_ptr->name2)
3803 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3804 switch(randint1(21))
3807 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3808 o_ptr->name2 = EGO_AMU_SLOW_D;
3811 if (o_ptr->pval) break;
3812 o_ptr->name2 = EGO_AMU_INFRA;
3815 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3816 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3819 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3820 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3823 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3824 o_ptr->name2 = EGO_AMU_LEVITATION;
3826 case 10: case 11: case 21:
3827 o_ptr->name2 = EGO_AMU_AC;
3830 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3831 if (m_bonus(10, level) > 8)
3832 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3834 o_ptr->name2 = EGO_AMU_RES_FIRE;
3837 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3838 if (m_bonus(10, level) > 8)
3839 o_ptr->name2 = EGO_AMU_RES_COLD_;
3841 o_ptr->name2 = EGO_AMU_RES_COLD;
3844 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3845 if (m_bonus(10, level) > 8)
3846 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3848 o_ptr->name2 = EGO_AMU_RES_ELEC;
3851 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3852 if (m_bonus(10, level) > 8)
3853 o_ptr->name2 = EGO_AMU_RES_ACID_;
3855 o_ptr->name2 = EGO_AMU_RES_ACID;
3857 case 16: case 17: case 18: case 19: case 20:
3858 switch (o_ptr->sval)
3860 case SV_AMULET_TELEPORT:
3861 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3862 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3863 else o_ptr->name2 = EGO_AMU_TELEPORT;
3865 case SV_AMULET_RESIST_ACID:
3866 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3868 case SV_AMULET_SEARCHING:
3869 o_ptr->name2 = EGO_AMU_STEALTH;
3871 case SV_AMULET_BRILLIANCE:
3872 if (!one_in_(3)) break;
3873 o_ptr->name2 = EGO_AMU_IDENT;
3875 case SV_AMULET_CHARISMA:
3876 if (!one_in_(3)) break;
3877 o_ptr->name2 = EGO_AMU_CHARM;
3879 case SV_AMULET_THE_MAGI:
3880 if (one_in_(2)) break;
3881 o_ptr->name2 = EGO_AMU_GREAT;
3883 case SV_AMULET_RESISTANCE:
3884 if (!one_in_(5)) break;
3885 o_ptr->name2 = EGO_AMU_DEFENDER;
3887 case SV_AMULET_TELEPATHY:
3888 if (!one_in_(3)) break;
3889 o_ptr->name2 = EGO_AMU_DETECTION;
3895 o_ptr->curse_flags = 0L;
3897 else if ((power == -2) && one_in_(2))
3899 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3900 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3901 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3902 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3903 o_ptr->art_flags[0] = 0;
3904 o_ptr->art_flags[1] = 0;
3905 while(!o_ptr->name2)
3907 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3911 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3912 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3915 o_ptr->name2 = EGO_AMU_FOOL;
3918 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3919 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3922 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3923 o_ptr->name2 = EGO_AMU_TY_CURSE;
3926 o_ptr->name2 = EGO_AMU_NAIVETY;
3931 o_ptr->ident |= (IDENT_BROKEN);
3934 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3942 * @brief モンスターが人形のベースにできるかを返す
3943 * @param r_idx チェックしたいモンスター種族のID
3944 * @return 人形にできるならTRUEを返す
3946 static bool item_monster_okay(MONRACE_IDX r_idx)
3948 monster_race *r_ptr = &r_info[r_idx];
3951 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3952 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3953 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3954 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3955 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3956 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3964 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3965 * Apply magic to an item known to be "boring"
3966 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3967 * @param level 生成基準階
3968 * @param power 生成ランク
3971 * Hack -- note the special code for various items
3973 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3975 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3980 /* Apply magic (good or bad) according to type */
3981 switch (o_ptr->tval)
3990 o_ptr->ident |= (IDENT_BROKEN);
3993 o_ptr->curse_flags |= (TRC_CURSED);
4000 o_ptr->xtra4 = o_ptr->pval;
4006 /* Hack -- Torches -- random fuel */
4007 if (o_ptr->sval == SV_LITE_TORCH)
4009 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4013 /* Hack -- Lanterns -- random fuel */
4014 if (o_ptr->sval == SV_LITE_LANTERN)
4016 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4020 if (power > 2) /* power > 2 is debug only */
4022 create_artifact(o_ptr, FALSE);
4024 else if ((power == 2) || ((power == 1) && one_in_(3)))
4026 while (!o_ptr->name2)
4030 bool okay_flag = TRUE;
4032 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4034 switch (o_ptr->name2)
4037 if (o_ptr->sval == SV_LITE_FEANOR)
4045 else if (power == -2)
4047 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4049 switch (o_ptr->name2)
4051 case EGO_LITE_DARKNESS:
4054 if (o_ptr->sval == SV_LITE_TORCH)
4056 add_flag(o_ptr->art_flags, TR_LITE_M1);
4058 else if (o_ptr->sval == SV_LITE_LANTERN)
4060 add_flag(o_ptr->art_flags, TR_LITE_M2);
4062 else if (o_ptr->sval == SV_LITE_FEANOR)
4064 add_flag(o_ptr->art_flags, TR_LITE_M3);
4076 /* The wand or staff gets a number of initial charges equal
4077 * to between 1/2 (+1) and the full object kind's pval. -LM-
4079 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4085 /* Transfer the pval. -LM- */
4086 o_ptr->pval = k_ptr->pval;
4093 object_aware(o_ptr);
4094 object_known(o_ptr);
4100 PARAMETER_VALUE i = 1;
4103 monster_race *r_ptr;
4105 /* Pick a random non-unique monster race */
4108 i = randint1(max_r_idx - 1);
4110 if (!item_monster_okay(i)) continue;
4111 if (i == MON_TSUCHINOKO) continue;
4115 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4117 /* Ignore dead monsters */
4118 if (!r_ptr->rarity) continue;
4120 /* Ignore uncommon monsters */
4121 if (r_ptr->rarity > 100) continue;
4123 /* Prefer less out-of-depth monsters */
4124 if (randint0(check)) continue;
4131 /* Some figurines are cursed */
4132 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4139 PARAMETER_VALUE i = 1;
4144 monster_race *r_ptr;
4146 if (o_ptr->sval == SV_SKELETON)
4148 match = RF9_DROP_SKELETON;
4150 else if (o_ptr->sval == SV_CORPSE)
4152 match = RF9_DROP_CORPSE;
4155 /* Hack -- Remove the monster restriction */
4156 get_mon_num_prep(item_monster_okay, NULL);
4158 /* Pick a random non-unique monster race */
4161 i = get_mon_num(dun_level);
4165 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4167 /* Ignore dead monsters */
4168 if (!r_ptr->rarity) continue;
4170 /* Ignore corpseless monsters */
4171 if (!(r_ptr->flags9 & match)) continue;
4173 /* Prefer less out-of-depth monsters */
4174 if (randint0(check)) continue;
4182 object_aware(o_ptr);
4183 object_known(o_ptr);
4189 PARAMETER_VALUE i = 1;
4191 monster_race *r_ptr;
4193 /* Pick a random monster race */
4196 i = randint1(max_r_idx - 1);
4200 /* Ignore dead monsters */
4201 if (!r_ptr->rarity) continue;
4210 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4212 object_aware(o_ptr);
4213 object_known(o_ptr);
4220 DEPTH obj_level = k_info[o_ptr->k_idx].level;
4222 /* Hack -- skip ruined chests */
4223 if (obj_level <= 0) break;
4225 /* Hack -- pick a "difficulty" */
4226 o_ptr->pval = randint1(obj_level);
4227 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4229 o_ptr->xtra3 = dun_level + 5;
4231 /* Never exceed "difficulty" of 55 to 59 */
4232 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4240 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4241 * Complete the "creation" of an object by applying "magic" to the item
4242 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4244 * @param mode 生成オプション
4247 * This includes not only rolling for random bonuses, but also putting the\n
4248 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4249 * staffs, giving fuel to lites, and placing traps on chests.\n
4251 * In particular, note that "Instant Artifacts", if "created" by an external\n
4252 * routine, must pass through this function to complete the actual creation.\n
4254 * The base "chance" of the item being "good" increases with the "level"\n
4255 * parameter, which is usually derived from the dungeon level, being equal\n
4256 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4257 * the object is guaranteed to be "good". If an object is "good", then\n
4258 * the chance that the object will be "great" (ego-item or artifact), also\n
4259 * increases with the "level", being equal to half the level, plus 5, up to\n
4260 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4261 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4263 * If the object is not "good", there is a chance it will be "cursed", and\n
4264 * if it is "cursed", there is a chance it will be "broken". These chances\n
4265 * are related to the "good" / "great" chances above.\n
4267 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4268 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4270 * If "okay" is true, and the object is going to be "great", then there is\n
4271 * a chance that an artifact will be created. This is true even if both the\n
4272 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4273 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4275 void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
4277 int i, rolls, f1, f2, power;
4279 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4281 /* Maximum "level" for various things */
4282 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4284 /* Base chance of being "good" */
4287 /* Maximal chance of being "good" */
4288 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4290 /* Base chance of being "great" */
4293 /* Maximal chance of being "great" */
4294 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4295 f2 = d_info[dungeon_type].obj_great;
4297 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4302 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4311 /* Roll for "good" */
4312 if ((mode & AM_GOOD) || magik(f1))
4317 /* Roll for "great" */
4318 if ((mode & AM_GREAT) || magik(f2))
4322 /* Roll for "special" */
4323 if (mode & AM_SPECIAL) power = 3;
4327 /* Roll for "cursed" */
4330 /* Assume "cursed" */
4333 /* Roll for "broken" */
4334 if (magik(f2)) power = -2;
4338 if (mode & AM_CURSED)
4340 /* Assume 'cursed' */
4345 /* Everything else gets more badly cursed */
4352 /* Assume no rolls */
4355 /* Get one roll if excellent */
4356 if (power >= 2) rolls = 1;
4358 /* Hack -- Get four rolls if forced great or special */
4359 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4361 /* Hack -- Get no rolls if not allowed */
4362 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4364 /* Roll for artifacts if allowed */
4365 for (i = 0; i < rolls; i++)
4367 /* Roll for an artifact */
4368 if (make_artifact(o_ptr)) break;
4369 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4371 if (make_artifact(o_ptr)) break;
4376 /* Hack -- analyze artifacts */
4377 if (object_is_fixed_artifact(o_ptr))
4379 artifact_type *a_ptr = &a_info[o_ptr->name1];
4381 /* Hack -- Mark the artifact as "created" */
4384 /* Hack -- Memorize location of artifact in saved floors */
4385 if (character_dungeon)
4386 a_ptr->floor_id = p_ptr->floor_id;
4388 /* Extract the other fields */
4389 o_ptr->pval = a_ptr->pval;
4390 o_ptr->ac = a_ptr->ac;
4391 o_ptr->dd = a_ptr->dd;
4392 o_ptr->ds = a_ptr->ds;
4393 o_ptr->to_a = a_ptr->to_a;
4394 o_ptr->to_h = a_ptr->to_h;
4395 o_ptr->to_d = a_ptr->to_d;
4396 o_ptr->weight = a_ptr->weight;
4397 o_ptr->xtra2 = a_ptr->act_idx;
4399 if (o_ptr->name1 == ART_MILIM)
4401 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4407 /* Hack -- extract the "broken" flag */
4408 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4410 /* Hack -- extract the "cursed" flag */
4411 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4412 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4413 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4414 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4415 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4416 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4424 switch (o_ptr->tval)
4433 if (power) a_m_aux_1(o_ptr, lev, power);
4439 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4445 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4459 /* Elven Cloak and Black Clothes ... */
4460 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4461 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4462 o_ptr->pval = randint1(4);
4466 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4467 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4468 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4469 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4470 a_m_aux_2(o_ptr, lev, power);
4472 if (power) a_m_aux_2(o_ptr, lev, power);
4480 if (!power && (randint0(100) < 50)) power = -1;
4481 a_m_aux_3(o_ptr, lev, power);
4487 a_m_aux_4(o_ptr, lev, power);
4492 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4493 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4494 (p_ptr->pseikaku == SEIKAKU_SEXY))
4497 add_flag(o_ptr->art_flags, TR_STR);
4498 add_flag(o_ptr->art_flags, TR_INT);
4499 add_flag(o_ptr->art_flags, TR_WIS);
4500 add_flag(o_ptr->art_flags, TR_DEX);
4501 add_flag(o_ptr->art_flags, TR_CON);
4502 add_flag(o_ptr->art_flags, TR_CHR);
4505 /* Hack -- analyze ego-items */
4506 if (object_is_ego(o_ptr))
4508 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4510 /* Hack -- acquire "broken" flag */
4511 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4513 /* Hack -- acquire "cursed" flag */
4514 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4515 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4516 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4517 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4518 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4519 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4521 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4522 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4523 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4524 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4525 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4526 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4527 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4528 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4534 while (one_in_(o_ptr->dd));
4536 if (o_ptr->dd > 9) o_ptr->dd = 9;
4539 /* Hack -- apply activatin index if needed */
4540 if (e_ptr->act_idx) o_ptr->xtra2 = (XTRA8)e_ptr->act_idx;
4542 /* Hack -- apply extra penalties if needed */
4543 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4545 /* Hack -- obtain bonuses */
4546 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4547 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4548 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4550 /* Hack -- obtain pval */
4551 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4554 /* Hack -- apply extra bonuses if needed */
4557 /* Hack -- obtain bonuses */
4558 if (e_ptr->max_to_h)
4560 if (e_ptr->max_to_h > 127)
4561 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4562 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4564 if (e_ptr->max_to_d)
4566 if (e_ptr->max_to_d > 127)
4567 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4568 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4570 if (e_ptr->max_to_a)
4572 if (e_ptr->max_to_a > 127)
4573 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4574 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4577 /* Accuracy ego must have high to_h */
4578 if(o_ptr->name2 == EGO_ACCURACY)
4580 while(o_ptr->to_h < o_ptr->to_d + 10)
4585 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4588 /* Accuracy ego must have high to_h */
4589 if(o_ptr->name2 == EGO_VELOCITY)
4591 while(o_ptr->to_d < o_ptr->to_h + 10)
4596 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4599 /* Protection ego must have high to_a */
4600 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4602 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4605 /* Hack -- obtain pval */
4606 if (e_ptr->max_pval)
4608 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4611 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4613 else if (o_ptr->name2 == EGO_DEMON)
4615 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4617 o_ptr->pval += randint1(2);
4621 o_ptr->pval += randint1(e_ptr->max_pval);
4624 else if (o_ptr->name2 == EGO_ATTACKS)
4626 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4627 if (o_ptr->pval > 3) o_ptr->pval = 3;
4628 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4629 o_ptr->pval += randint1(2);
4631 else if (o_ptr->name2 == EGO_BAT)
4633 o_ptr->pval = randint1(e_ptr->max_pval);
4634 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4636 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4638 o_ptr->pval = randint1(e_ptr->max_pval);
4642 o_ptr->pval += randint1(e_ptr->max_pval);
4647 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4649 o_ptr->pval = randint1(o_ptr->pval);
4651 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4659 /* Examine real objects */
4662 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4664 /* Hack -- acquire "broken" flag */
4665 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4667 /* Hack -- acquire "cursed" flag */
4668 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4669 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4670 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4671 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4672 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4673 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4681 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4682 * Hack -- determine if a template is "good"
4683 * @param k_idx 判定したいベースアイテムのID
4684 * @return ベースアイテムが上質ならばTRUEを返す。
4686 static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4688 object_kind *k_ptr = &k_info[k_idx];
4690 /* Analyze the item type */
4691 switch (k_ptr->tval)
4693 /* Armor -- Good unless damaged */
4704 if (k_ptr->to_a < 0) return (FALSE);
4708 /* Weapons -- Good unless damaged */
4715 if (k_ptr->to_h < 0) return (FALSE);
4716 if (k_ptr->to_d < 0) return (FALSE);
4720 /* Ammo -- Arrows/Bolts are good */
4727 /* Books -- High level books are good (except Arcane books) */
4729 case TV_SORCERY_BOOK:
4730 case TV_NATURE_BOOK:
4735 case TV_DAEMON_BOOK:
4736 case TV_CRUSADE_BOOK:
4738 case TV_HISSATSU_BOOK:
4741 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4745 /* Rings -- Rings of Speed are good */
4748 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4749 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4753 /* Amulets -- Amulets of the Magi and Resistance are good */
4756 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4757 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4762 /* Assume not good */
4767 * @brief 生成階に応じたベースアイテムの生成を行う。
4768 * Attempt to make an object (normal or good/great)
4769 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4770 * @param mode オプションフラグ
4771 * @return 生成に成功したらTRUEを返す。
4773 * This routine plays nasty games to generate the "special artifacts".\n
4774 * This routine uses "object_level" for the "generation level".\n
4775 * We assume that the given object has been "wiped".\n
4777 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
4782 /* Chance of "special object" */
4783 prob = ((mode & AM_GOOD) ? 10 : 1000);
4785 /* Base level for the object */
4786 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4789 /* Generate a special object, or a normal object */
4790 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4795 if ((mode & AM_GOOD) && !get_obj_num_hook)
4797 /* Activate restriction (if already specified, use that) */
4798 get_obj_num_hook = kind_is_good;
4801 /* Restricted objects - prepare allocation table */
4802 if (get_obj_num_hook) get_obj_num_prep();
4804 /* Pick a random object */
4805 k_idx = get_obj_num(base);
4807 /* Restricted objects */
4808 if (get_obj_num_hook)
4810 /* Clear restriction */
4811 get_obj_num_hook = NULL;
4813 /* Reset allocation table to default */
4817 /* Handle failure */
4818 if (!k_idx) return (FALSE);
4820 /* Prepare the object */
4821 object_prep(j_ptr, k_idx);
4824 /* Apply magic (allow artifacts) */
4825 apply_magic(j_ptr, object_level, mode);
4827 /* Hack -- generate multiple spikes/missiles */
4828 switch (j_ptr->tval)
4836 j_ptr->number = (byte)damroll(6, 7);
4840 if (cheat_peek) object_mention(j_ptr);
4848 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4849 * Attempt to place an object (normal or good/great) at the given location.
4850 * @param y 配置したいフロアのY座標
4851 * @param x 配置したいフロアのX座標
4852 * @param mode オプションフラグ
4853 * @return 生成に成功したらTRUEを返す。
4855 * This routine plays nasty games to generate the "special artifacts".\n
4856 * This routine uses "object_level" for the "generation level".\n
4857 * This routine requires a clean floor grid destination.\n
4859 void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
4864 cave_type *c_ptr = &cave[y][x];
4870 /* Paranoia -- check bounds */
4871 if (!in_bounds(y, x)) return;
4873 /* Require floor space */
4874 if (!cave_drop_bold(y, x)) return;
4876 /* Avoid stacking on other objects */
4877 if (c_ptr->o_idx) return;
4880 /* Get local object */
4883 /* Wipe the object */
4886 /* Make an object (if possible) */
4887 if (!make_object(q_ptr, mode)) return;
4890 /* Make an object */
4898 /* Acquire object */
4899 o_ptr = &o_list[o_idx];
4901 /* Structure Copy */
4902 object_copy(o_ptr, q_ptr);
4909 o_ptr->next_o_idx = c_ptr->o_idx;
4911 /* Place the object */
4912 c_ptr->o_idx = o_idx;
4922 /* Hack -- Preserve artifacts */
4923 if (object_is_fixed_artifact(q_ptr))
4925 a_info[q_ptr->name1].cur_num = 0;
4932 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4933 * Make a treasure object
4934 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4935 * @return 生成に成功したらTRUEを返す。
4937 * The location must be a legal, clean, floor grid.
4939 bool make_gold(object_type *j_ptr)
4946 /* Hack -- Pick a Treasure variety */
4947 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4949 /* Apply "extra" magic */
4950 if (one_in_(GREAT_OBJ))
4952 i += randint1(object_level + 1);
4955 /* Hack -- Creeping Coins only generate "themselves" */
4956 if (coin_type) i = coin_type;
4958 /* Do not create "illegal" Treasure Types */
4959 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4961 /* Prepare a gold object */
4962 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4964 /* Hack -- Base coin cost */
4965 base = k_info[OBJ_GOLD_LIST+i].cost;
4967 /* Determine how much the treasure is "worth" */
4968 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4976 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
4977 * Places a treasure (Gold or Gems) at given location
4978 * @param y 配置したいフロアのY座標
4979 * @param x 配置したいフロアのX座標
4980 * @return 生成に成功したらTRUEを返す。
4982 * The location must be a legal, clean, floor grid.
4984 void place_gold(POSITION y, POSITION x)
4989 cave_type *c_ptr = &cave[y][x];
4996 /* Paranoia -- check bounds */
4997 if (!in_bounds(y, x)) return;
4999 /* Require floor space */
5000 if (!cave_drop_bold(y, x)) return;
5002 /* Avoid stacking on other objects */
5003 if (c_ptr->o_idx) return;
5006 /* Get local object */
5009 /* Wipe the object */
5012 /* Make some gold */
5013 if (!make_gold(q_ptr)) return;
5016 /* Make an object */
5024 /* Acquire object */
5025 o_ptr = &o_list[o_idx];
5027 /* Copy the object */
5028 object_copy(o_ptr, q_ptr);
5035 o_ptr->next_o_idx = c_ptr->o_idx;
5037 /* Place the object */
5038 c_ptr->o_idx = o_idx;
5050 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5051 * Let an object fall to the ground at or near a location.
5052 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5053 * @param chance ドロップの成功率(%)
5054 * @param y 配置したいフロアのY座標
5055 * @param x 配置したいフロアのX座標
5056 * @return 生成に成功したらTRUEを返す。
5058 * The initial location is assumed to be "in_bounds()".\n
5060 * This function takes a parameter "chance". This is the percentage\n
5061 * chance that the item will "disappear" instead of drop. If the object\n
5062 * has been thrown, then this is the chance of disappearance on contact.\n
5064 * Hack -- this function uses "chance" to determine if it should produce\n
5065 * some form of "description" of the drop event (under the player).\n
5067 * We check several locations to see if we can find a location at which\n
5068 * the object can combine, stack, or be placed. Artifacts will try very\n
5069 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5071 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5082 s16b this_o_idx, next_o_idx = 0;
5086 char o_name[MAX_NLEN];
5092 /* Extract plural */
5093 bool plural = (j_ptr->number != 1);
5096 /* Describe object */
5097 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5100 /* Handle normal "breakage" */
5101 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5105 msg_format("%sは消えた。", o_name);
5107 msg_format("The %s disappear%s.",
5108 o_name, (plural ? "" : "s"));
5113 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5130 /* Scan local grids */
5131 for (dy = -3; dy <= 3; dy++)
5133 /* Scan local grids */
5134 for (dx = -3; dx <= 3; dx++)
5138 /* Calculate actual distance */
5139 d = (dy * dy) + (dx * dx);
5141 /* Ignore distant grids */
5142 if (d > 10) continue;
5148 /* Skip illegal grids */
5149 if (!in_bounds(ty, tx)) continue;
5151 /* Require line of projection */
5152 if (!projectable(y, x, ty, tx)) continue;
5155 c_ptr = &cave[ty][tx];
5157 /* Require floor space */
5158 if (!cave_drop_bold(ty, tx)) continue;
5163 /* Scan objects in that grid */
5164 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5168 /* Acquire object */
5169 o_ptr = &o_list[this_o_idx];
5171 /* Acquire next object */
5172 next_o_idx = o_ptr->next_o_idx;
5174 /* Check for possible combination */
5175 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5181 /* Add new object */
5185 if (k > 99) continue;
5187 /* Calculate score */
5188 s = 1000 - (d + k * 5);
5190 /* Skip bad values */
5191 if (s < bs) continue;
5193 /* New best value */
5196 /* Apply the randomizer to equivalent values */
5197 if ((++bn >= 2) && !one_in_(bn)) continue;
5212 /* Handle lack of space */
5213 if (!flag && !object_is_artifact(j_ptr))
5217 msg_format("%sは消えた。", o_name);
5219 msg_format("The %s disappear%s.",
5220 o_name, (plural ? "" : "s"));
5225 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5233 for (i = 0; !flag && (i < 1000); i++)
5236 ty = rand_spread(by, 1);
5237 tx = rand_spread(bx, 1);
5239 /* Verify location */
5240 if (!in_bounds(ty, tx)) continue;
5242 /* Bounce to that location */
5246 /* Require floor space */
5247 if (!cave_drop_bold(by, bx)) continue;
5256 int candidates = 0, pick;
5258 for (ty = 1; ty < cur_hgt - 1; ty++)
5260 for (tx = 1; tx < cur_wid - 1; tx++)
5262 /* A valid space found */
5263 if (cave_drop_bold(ty, tx)) candidates++;
5267 /* No valid place! */
5272 msg_format("%sは消えた。", o_name);
5274 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5278 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5280 /* Mega-Hack -- preserve artifacts */
5283 /* Hack -- Preserve unknown artifacts */
5284 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5286 /* Mega-Hack -- Preserve the artifact */
5287 a_info[j_ptr->name1].cur_num = 0;
5295 /* Choose a random one */
5296 pick = randint1(candidates);
5298 for (ty = 1; ty < cur_hgt - 1; ty++)
5300 for (tx = 1; tx < cur_wid - 1; tx++)
5302 if (cave_drop_bold(ty, tx))
5306 /* Is this a picked one? */
5320 c_ptr = &cave[by][bx];
5322 /* Scan objects in that grid for combination */
5323 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5327 /* Acquire object */
5328 o_ptr = &o_list[this_o_idx];
5330 /* Acquire next object */
5331 next_o_idx = o_ptr->next_o_idx;
5333 /* Check for combination */
5334 if (object_similar(o_ptr, j_ptr))
5336 /* Combine the items */
5337 object_absorb(o_ptr, j_ptr);
5347 /* Get new object */
5348 if (!done) o_idx = o_pop();
5351 if (!done && !o_idx)
5355 msg_format("%sは消えた。", o_name);
5357 msg_format("The %s disappear%s.",
5358 o_name, (plural ? "" : "s"));
5363 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5365 /* Hack -- Preserve artifacts */
5366 if (object_is_fixed_artifact(j_ptr))
5368 a_info[j_ptr->name1].cur_num = 0;
5378 /* Structure copy */
5379 object_copy(&o_list[o_idx], j_ptr);
5381 /* Access new object */
5382 j_ptr = &o_list[o_idx];
5389 j_ptr->held_m_idx = 0;
5392 j_ptr->next_o_idx = c_ptr->o_idx;
5394 /* Place the object */
5395 c_ptr->o_idx = o_idx;
5410 /* Mega-Hack -- no message if "dropped" by player */
5411 /* Message when an object falls under the player */
5412 if (chance && player_bold(by, bx))
5414 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5426 * Scatter some "great" objects near the player
5427 * @param y1 配置したいフロアのY座標
5428 * @param x1 配置したいフロアのX座標
5429 * @param num 獲得の処理回数
5430 * @param great TRUEならば必ず高級品以上を落とす
5431 * @param special TRUEならば必ず特別品を落とす
5432 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5435 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5438 object_type object_type_body;
5439 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5444 /* Get local object */
5445 i_ptr = &object_type_body;
5447 /* Wipe the object */
5450 /* Make a good (or great) object (if possible) */
5451 if (!make_object(i_ptr, mode)) continue;
5455 object_aware(i_ptr);
5456 object_known(i_ptr);
5459 /* Drop the object */
5460 (void)drop_near(i_ptr, -1, y1, x1);
5465 * Scatter some "amusing" objects near the player
5468 #define AMS_NOTHING 0x00 /* No restriction */
5469 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5470 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5471 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5472 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5476 OBJECT_TYPE_VALUE tval;
5477 OBJECT_SUBTYPE_VALUE sval;
5482 amuse_type amuse_info[] =
5484 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5485 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5486 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5487 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5488 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5489 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5490 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5491 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5492 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5493 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5494 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5495 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5496 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5503 * @param y1 配置したいフロアのY座標
5504 * @param x1 配置したいフロアのX座標
5505 * @param num 誰得の処理回数
5506 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5509 void amusement(int y1, int x1, int num, bool known)
5512 object_type object_type_body;
5515 for (n = 0; amuse_info[n].tval != 0; n++)
5517 t += amuse_info[n].prob;
5524 IDX k_idx, a_idx = 0;
5525 int r = randint0(t);
5526 bool insta_art, fixed_art;
5530 r -= amuse_info[i].prob;
5534 /* Get local object */
5535 i_ptr = &object_type_body;
5537 /* Wipe the object */
5540 /* Wipe the object */
5541 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5543 /* Paranoia - reroll if nothing */
5544 if (!k_idx) continue;
5546 /* Search an artifact index if need */
5547 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5548 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5550 if (insta_art || fixed_art)
5552 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5554 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5555 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5556 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5557 if (a_info[a_idx].cur_num > 0) continue;
5561 if (a_idx >= max_a_idx) continue;
5564 /* Make an object (if possible) */
5565 object_prep(i_ptr, k_idx);
5566 if (a_idx) i_ptr->name1 = a_idx;
5567 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5569 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5571 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5574 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5575 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5579 object_aware(i_ptr);
5580 object_known(i_ptr);
5583 /* Paranoia - reroll if nothing */
5584 if (!(i_ptr->k_idx)) continue;
5586 /* Drop the object */
5587 (void)drop_near(i_ptr, -1, y1, x1);
5594 #define MAX_NORMAL_TRAPS 18
5596 /* See init_feat_variables() in init2.c */
5597 static s16b normal_traps[MAX_NORMAL_TRAPS];
5600 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5603 void init_normal_traps(void)
5607 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5608 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5609 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5610 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5611 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5612 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5613 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5614 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5615 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5616 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5617 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5618 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5619 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5620 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5621 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5622 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5623 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5624 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5628 * @brief 基本トラップをランダムに選択する /
5630 * @return 選択したトラップのID
5632 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5633 * That is, it does not make sense to have spiked pits at 50 feet.\n
5634 * Actually, it is not this routine, but the "trap instantiation"\n
5635 * code, which should also check for "trap doors" on quest levels.\n
5637 s16b choose_random_trap(void)
5644 /* Hack -- pick a trap */
5645 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5647 /* Accept non-trapdoors */
5648 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5650 /* Hack -- no trap doors on special levels */
5651 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5653 /* Hack -- no trap doors on the deepest level */
5654 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5663 * @brief マスに存在するトラップを秘匿する /
5664 * Disclose an invisible trap
5665 * @param y 秘匿したいマスのY座標
5666 * @param x 秘匿したいマスのX座標
5669 void disclose_grid(int y, int x)
5671 cave_type *c_ptr = &cave[y][x];
5673 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5675 /* No longer hidden */
5676 cave_alter_feat(y, x, FF_SECRET);
5678 else if (c_ptr->mimic)
5680 /* No longer hidden */
5692 * @brief マスをトラップを配置する /
5693 * The location must be a legal, naked, floor grid.
5694 * @param y 配置したいマスのY座標
5695 * @param x 配置したいマスのX座標
5697 * Note that all traps start out as "invisible" and "untyped", and then\n
5698 * when they are "discovered" (by detecting them or setting them off),\n
5699 * the trap is "instantiated" as a visible, "typed", trap.\n
5701 void place_trap(int y, int x)
5703 cave_type *c_ptr = &cave[y][x];
5705 /* Paranoia -- verify location */
5706 if (!in_bounds(y, x)) return;
5708 /* Require empty, clean, floor grid */
5709 if (!cave_clean_bold(y, x)) return;
5711 /* Place an invisible trap */
5712 c_ptr->mimic = c_ptr->feat;
5713 c_ptr->feat = choose_random_trap();
5717 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5718 * Describe the charges on an item in the inventory.
5719 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5722 void inven_item_charges(int item)
5724 object_type *o_ptr = &inventory[item];
5726 /* Require staff/wand */
5727 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5729 /* Require known item */
5730 if (!object_is_known(o_ptr)) return;
5733 if (o_ptr->pval <= 0)
5735 msg_print("もう魔力が残っていない。");
5739 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5742 /* Multiple charges */
5743 if (o_ptr->pval != 1)
5745 /* Print a message */
5746 msg_format("You have %d charges remaining.", o_ptr->pval);
5752 /* Print a message */
5753 msg_format("You have %d charge remaining.", o_ptr->pval);
5760 * @brief アイテムの残り所持数メッセージを表示する /
5761 * Describe an item in the inventory.
5762 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5765 void inven_item_describe(int item)
5767 object_type *o_ptr = &inventory[item];
5768 char o_name[MAX_NLEN];
5770 /* Get a description */
5771 object_desc(o_name, o_ptr, 0);
5773 /* Print a message */
5775 /* "no more" の場合はこちらで表示する */
5776 if (o_ptr->number <= 0)
5778 /*FIRST*//*ここはもう通らないかも */
5779 msg_format("もう%sを持っていない。", o_name);
5783 /* アイテム名を英日切り替え機能対応 */
5784 msg_format("まだ %sを持っている。", o_name);
5787 msg_format("You have %s.", o_name);
5793 * @brief アイテムの残り所持数メッセージを表示する /
5794 * Increase the "number" of an item in the inventory
5795 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5799 void inven_item_increase(int item, int num)
5801 object_type *o_ptr = &inventory[item];
5804 num += o_ptr->number;
5807 if (num > 255) num = 255;
5808 else if (num < 0) num = 0;
5811 num -= (ITEM_NUMBER)o_ptr->number;
5813 /* Change the number and weight */
5816 /* Add the number */
5817 o_ptr->number += num;
5819 /* Add the weight */
5820 p_ptr->total_weight += (num * o_ptr->weight);
5822 /* Recalculate bonuses */
5823 p_ptr->update |= (PU_BONUS);
5825 /* Recalculate mana XXX */
5826 p_ptr->update |= (PU_MANA);
5828 /* Combine the pack */
5829 p_ptr->notice |= (PN_COMBINE);
5832 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5834 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5835 if (!o_ptr->number && p_ptr->ele_attack)
5837 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5839 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5841 /* Clear all temporary elemental brands */
5842 set_ele_attack(0, 0);
5850 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5851 * Erase an inventory slot if it has no more items
5852 * @param item 消去したいプレイヤーのアイテム所持スロット
5855 void inven_item_optimize(int item)
5857 object_type *o_ptr = &inventory[item];
5859 /* Only optimize real items */
5860 if (!o_ptr->k_idx) return;
5862 /* Only optimize empty items */
5863 if (o_ptr->number) return;
5865 /* The item is in the pack */
5866 if (item < INVEN_RARM)
5873 /* Slide everything down */
5874 for (i = item; i < INVEN_PACK; i++)
5876 /* Structure copy */
5877 inventory[i] = inventory[i+1];
5880 /* Erase the "final" slot */
5881 object_wipe(&inventory[i]);
5884 p_ptr->window |= (PW_INVEN);
5887 /* The item is being wielded */
5893 /* Erase the empty slot */
5894 object_wipe(&inventory[item]);
5896 /* Recalculate bonuses */
5897 p_ptr->update |= (PU_BONUS);
5899 /* Recalculate torch */
5900 p_ptr->update |= (PU_TORCH);
5902 /* Recalculate mana XXX */
5903 p_ptr->update |= (PU_MANA);
5906 p_ptr->window |= (PW_EQUIP);
5910 p_ptr->window |= (PW_SPELL);
5914 * @brief 床上の魔道具の残り残量メッセージを表示する /
5915 * Describe the charges on an item on the floor.
5916 * @param item メッセージの対象にしたいアイテム所持スロット
5919 void floor_item_charges(int item)
5921 object_type *o_ptr = &o_list[item];
5923 /* Require staff/wand */
5924 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5926 /* Require known item */
5927 if (!object_is_known(o_ptr)) return;
5930 if (o_ptr->pval <= 0)
5932 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5936 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5939 /* Multiple charges */
5940 if (o_ptr->pval != 1)
5942 /* Print a message */
5943 msg_format("There are %d charges remaining.", o_ptr->pval);
5949 /* Print a message */
5950 msg_format("There is %d charge remaining.", o_ptr->pval);
5957 * @brief 床上のアイテムの残り数メッセージを表示する /
5958 * Describe the charges on an item on the floor.
5959 * @param item メッセージの対象にしたいアイテム所持スロット
5962 void floor_item_describe(int item)
5964 object_type *o_ptr = &o_list[item];
5965 char o_name[MAX_NLEN];
5967 /* Get a description */
5968 object_desc(o_name, o_ptr, 0);
5970 /* Print a message */
5972 /* "no more" の場合はこちらで表示を分ける */
5973 if (o_ptr->number <= 0)
5975 msg_format("床上には、もう%sはない。", o_name);
5979 msg_format("床上には、まだ %sがある。", o_name);
5982 msg_format("You see %s.", o_name);
5989 * @brief 床上のアイテムの数を増やす /
5990 * Increase the "number" of an item on the floor
5991 * @param item 増やしたいアイテムの所持スロット
5992 * @param num 増やしたいアイテムの数
5995 void floor_item_increase(int item, int num)
5997 object_type *o_ptr = &o_list[item];
6000 num += o_ptr->number;
6003 if (num > 255) num = 255;
6004 else if (num < 0) num = 0;
6007 num -= (int)o_ptr->number;
6009 /* Change the number */
6010 o_ptr->number += (ITEM_NUMBER)num;
6015 * @brief 床上の数の無くなったアイテムスロットを消去する /
6016 * Optimize an item on the floor (destroy "empty" items)
6017 * @param item 消去したいアイテムの所持スロット
6020 void floor_item_optimize(int item)
6022 object_type *o_ptr = &o_list[item];
6024 /* Paranoia -- be sure it exists */
6025 if (!o_ptr->k_idx) return;
6027 /* Only optimize empty items */
6028 if (o_ptr->number) return;
6030 /* Delete the object */
6031 delete_object_idx(item);
6036 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6037 * Check if we have space for an item in the pack without overflow
6038 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6039 * @return 溢れずに済むならTRUEを返す
6041 bool inven_carry_okay(object_type *o_ptr)
6046 if (inven_cnt < INVEN_PACK) return (TRUE);
6049 for (j = 0; j < INVEN_PACK; j++)
6051 object_type *j_ptr = &inventory[j];
6053 /* Skip non-objects */
6054 if (!j_ptr->k_idx) continue;
6056 /* Check if the two items can be combined */
6057 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6065 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6066 * Check if we have space for an item in the pack without overflow
6067 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6068 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6069 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6070 * @return o_ptrの方が上位ならばTRUEを返す。
6072 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6076 /* Use empty slots */
6077 if (!j_ptr->k_idx) return TRUE;
6079 /* Hack -- readable books always come first */
6080 if ((o_ptr->tval == REALM1_BOOK) &&
6081 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6082 if ((j_ptr->tval == REALM1_BOOK) &&
6083 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6085 if ((o_ptr->tval == REALM2_BOOK) &&
6086 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6087 if ((j_ptr->tval == REALM2_BOOK) &&
6088 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6090 /* Objects sort by decreasing type */
6091 if (o_ptr->tval > j_ptr->tval) return TRUE;
6092 if (o_ptr->tval < j_ptr->tval) return FALSE;
6094 /* Non-aware (flavored) items always come last */
6095 /* Can happen in the home */
6096 if (!object_is_aware(o_ptr)) return FALSE;
6097 if (!object_is_aware(j_ptr)) return TRUE;
6099 /* Objects sort by increasing sval */
6100 if (o_ptr->sval < j_ptr->sval) return TRUE;
6101 if (o_ptr->sval > j_ptr->sval) return FALSE;
6103 /* Unidentified objects always come last */
6104 /* Objects in the home can be unknown */
6105 if (!object_is_known(o_ptr)) return FALSE;
6106 if (!object_is_known(j_ptr)) return TRUE;
6108 /* Fixed artifacts, random artifacts and ego items */
6109 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6110 else if (o_ptr->art_name) o_type = 2;
6111 else if (object_is_ego(o_ptr)) o_type = 1;
6114 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6115 else if (j_ptr->art_name) j_type = 2;
6116 else if (object_is_ego(j_ptr)) j_type = 1;
6119 if (o_type < j_type) return TRUE;
6120 if (o_type > j_type) return FALSE;
6122 switch (o_ptr->tval)
6128 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6129 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6135 /* Objects sort by increasing hit/damage bonuses */
6136 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6137 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6140 /* Hack: otherwise identical rods sort by
6141 increasing recharge time --dsb */
6143 if (o_ptr->pval < j_ptr->pval) return TRUE;
6144 if (o_ptr->pval > j_ptr->pval) return FALSE;
6148 /* Objects sort by decreasing value */
6149 return o_value > object_value(j_ptr);
6154 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6155 * Add an item to the players inventory, and return the slot used.
6156 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6157 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6159 * If the new item can combine with an existing item in the inventory,\n
6160 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6161 * the item will be placed into the "proper" location in the inventory.\n
6163 * This function can be used to "over-fill" the player's pack, but only\n
6164 * once, and such an action must trigger the "overflow" code immediately.\n
6165 * Note that when the pack is being "over-filled", the new item must be\n
6166 * placed into the "overflow" slot, and the "overflow" must take place\n
6167 * before the pack is reordered, but (optionally) after the pack is\n
6168 * combined. This may be tricky. See "dungeon.c" for info.\n
6170 * Note that this code must remove any location/stack information\n
6171 * from the object once it is placed into the inventory.\n
6173 s16b inven_carry(object_type *o_ptr)
6175 INVENTORY_IDX i, j, k;
6176 INVENTORY_IDX n = -1;
6181 /* Check for combining */
6182 for (j = 0; j < INVEN_PACK; j++)
6184 j_ptr = &inventory[j];
6186 /* Skip non-objects */
6187 if (!j_ptr->k_idx) continue;
6189 /* Hack -- track last item */
6192 /* Check if the two items can be combined */
6193 if (object_similar(j_ptr, o_ptr))
6195 /* Combine the items */
6196 object_absorb(j_ptr, o_ptr);
6198 /* Increase the weight */
6199 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6201 /* Recalculate bonuses */
6202 p_ptr->update |= (PU_BONUS);
6205 p_ptr->window |= (PW_INVEN);
6214 if (inven_cnt > INVEN_PACK) return (-1);
6216 /* Find an empty slot */
6217 for (j = 0; j <= INVEN_PACK; j++)
6219 j_ptr = &inventory[j];
6221 /* Use it if found */
6222 if (!j_ptr->k_idx) break;
6229 /* Reorder the pack */
6232 /* Get the "value" of the item */
6233 s32b o_value = object_value(o_ptr);
6235 /* Scan every occupied slot */
6236 for (j = 0; j < INVEN_PACK; j++)
6238 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6245 for (k = n; k >= i; k--)
6247 /* Hack -- Slide the item */
6248 object_copy(&inventory[k+1], &inventory[k]);
6251 /* Wipe the empty slot */
6252 object_wipe(&inventory[i]);
6257 object_copy(&inventory[i], o_ptr);
6259 /* Access new object */
6260 j_ptr = &inventory[i];
6263 j_ptr->next_o_idx = 0;
6265 /* Forget monster */
6266 j_ptr->held_m_idx = 0;
6268 /* Forget location */
6269 j_ptr->iy = j_ptr->ix = 0;
6271 /* Player touches it, and no longer marked */
6272 j_ptr->marked = OM_TOUCHED;
6274 /* Increase the weight */
6275 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6277 /* Count the items */
6280 /* Recalculate bonuses */
6281 p_ptr->update |= (PU_BONUS);
6283 /* Combine and Reorder pack */
6284 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6287 p_ptr->window |= (PW_INVEN);
6289 /* Return the slot */
6295 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6296 * Take off (some of) a non-cursed equipment item
6297 * @param item オブジェクトを外したい所持テーブルのID
6299 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6301 * Note that only one item at a time can be wielded per slot.\n
6302 * Note that taking off an item when "full" may cause that item\n
6303 * to fall to the ground.\n
6304 * Return the inventory slot into which the item is placed.\n
6306 INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
6317 char o_name[MAX_NLEN];
6320 /* Get the item to take off */
6321 o_ptr = &inventory[item];
6324 if (amt <= 0) return (-1);
6327 if (amt > o_ptr->number) amt = o_ptr->number;
6329 /* Get local object */
6332 /* Obtain a local object */
6333 object_copy(q_ptr, o_ptr);
6335 /* Modify quantity */
6336 q_ptr->number = amt;
6338 /* Describe the object */
6339 object_desc(o_name, q_ptr, 0);
6341 /* Took off weapon */
6342 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6343 object_is_melee_weapon(o_ptr))
6345 act = _("を装備からはずした", "You were wielding");
6349 else if (item == INVEN_BOW)
6351 act = _("を装備からはずした", "You were holding");
6354 /* Took off light */
6355 else if (item == INVEN_LITE)
6357 act = _("を光源からはずした", "You were holding");
6360 /* Took off something */
6363 act = _("を装備からはずした", "You were wearing");
6366 /* Modify, Optimize */
6367 inven_item_increase(item, -amt);
6368 inven_item_optimize(item);
6370 /* Carry the object */
6371 slot = inven_carry(q_ptr);
6375 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6377 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6387 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6388 * Drop (some of) a non-cursed inventory/equipment item
6389 * @param item 所持テーブルのID
6390 * @param amt 落としたい個数
6393 * The object will be dropped "near" the current location
6395 void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
6401 char o_name[MAX_NLEN];
6404 /* Access original object */
6405 o_ptr = &inventory[item];
6408 if (amt <= 0) return;
6411 if (amt > o_ptr->number) amt = o_ptr->number;
6414 /* Take off equipment */
6415 if (item >= INVEN_RARM)
6417 /* Take off first */
6418 item = inven_takeoff(item, amt);
6420 /* Access original object */
6421 o_ptr = &inventory[item];
6425 /* Get local object */
6428 /* Obtain local object */
6429 object_copy(q_ptr, o_ptr);
6431 /* Distribute charges of wands or rods */
6432 distribute_charges(o_ptr, q_ptr, amt);
6434 /* Modify quantity */
6435 q_ptr->number = amt;
6437 /* Describe local object */
6438 object_desc(o_name, q_ptr, 0);
6441 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6443 /* Drop it near the player */
6444 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6446 /* Modify, Describe, Optimize */
6447 inven_item_increase(item, -amt);
6448 inven_item_describe(item);
6449 inven_item_optimize(item);
6454 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6455 * Combine items in the pack
6458 * Note special handling of the "overflow" slot
6460 void combine_pack(void)
6465 bool flag = FALSE, combined;
6471 /* Combine the pack (backwards) */
6472 for (i = INVEN_PACK; i > 0; i--)
6475 o_ptr = &inventory[i];
6477 /* Skip empty items */
6478 if (!o_ptr->k_idx) continue;
6480 /* Scan the items above that item */
6481 for (j = 0; j < i; j++)
6486 j_ptr = &inventory[j];
6488 /* Skip empty items */
6489 if (!j_ptr->k_idx) continue;
6492 * Get maximum number of the stack if these
6493 * are similar, get zero otherwise.
6495 max_num = object_similar_part(j_ptr, o_ptr);
6497 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6498 if (max_num && j_ptr->number < max_num)
6500 if (o_ptr->number + j_ptr->number <= max_num)
6505 /* Add together the item counts */
6506 object_absorb(j_ptr, o_ptr);
6508 /* One object is gone */
6511 /* Slide everything down */
6512 for (k = i; k < INVEN_PACK; k++)
6514 /* Structure copy */
6515 inventory[k] = inventory[k+1];
6518 /* Erase the "final" slot */
6519 object_wipe(&inventory[k]);
6523 int old_num = o_ptr->number;
6524 int remain = j_ptr->number + o_ptr->number - max_num;
6526 o_ptr->number -= remain;
6528 /* Add together the item counts */
6529 object_absorb(j_ptr, o_ptr);
6531 o_ptr->number = remain;
6533 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6534 if (o_ptr->tval == TV_ROD)
6536 o_ptr->pval = o_ptr->pval * remain / old_num;
6537 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6540 /* Hack -- if wands are stacking, combine the charges. -LM- */
6541 if (o_ptr->tval == TV_WAND)
6543 o_ptr->pval = o_ptr->pval * remain / old_num;
6548 p_ptr->window |= (PW_INVEN);
6562 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6566 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6567 * Reorder items in the pack
6570 * Note special handling of the "overflow" slot
6572 void reorder_pack(void)
6582 /* Re-order the pack (forwards) */
6583 for (i = 0; i < INVEN_PACK; i++)
6585 /* Mega-Hack -- allow "proper" over-flow */
6586 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6589 o_ptr = &inventory[i];
6591 /* Skip empty slots */
6592 if (!o_ptr->k_idx) continue;
6594 /* Get the "value" of the item */
6595 o_value = object_value(o_ptr);
6597 /* Scan every occupied slot */
6598 for (j = 0; j < INVEN_PACK; j++)
6600 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6603 /* Never move down */
6604 if (j >= i) continue;
6609 /* Get local object */
6612 /* Save a copy of the moving item */
6613 object_copy(q_ptr, &inventory[i]);
6615 /* Slide the objects */
6616 for (k = i; k > j; k--)
6618 /* Slide the item */
6619 object_copy(&inventory[k], &inventory[k-1]);
6622 /* Insert the moving item */
6623 object_copy(&inventory[j], q_ptr);
6626 p_ptr->window |= (PW_INVEN);
6630 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6634 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6635 * Hack -- display an object kind in the current window
6636 * @param k_idx ベースアイテムの参照ID
6639 * Include list of usable spells for readible books
6641 void display_koff(IDX k_idx)
6648 REALM_IDX use_realm;
6650 char o_name[MAX_NLEN];
6653 /* Erase the window */
6654 for (y = 0; y < Term->hgt; y++)
6656 /* Erase the line */
6657 Term_erase(0, y, 255);
6663 /* Get local object */
6666 /* Prepare the object */
6667 object_prep(q_ptr, k_idx);
6670 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6672 /* Mention the object name */
6673 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6675 /* Access the item's sval */
6677 use_realm = tval2realm(q_ptr->tval);
6679 /* Warriors are illiterate */
6680 if (p_ptr->realm1 || p_ptr->realm2)
6682 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6686 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6687 if (!is_magic(use_realm)) return;
6688 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6691 /* Display spells in readible books */
6695 SPELL_IDX spells[64];
6697 /* Extract spells */
6698 for (spell = 0; spell < 32; spell++)
6700 /* Check for this spell */
6701 if (fake_spell_flags[sval] & (1L << spell))
6703 /* Collect this spell */
6704 spells[num++] = spell;
6709 print_spells(0, spells, num, 2, 0, use_realm);
6714 * @brief 警告を放つアイテムを選択する /
6715 * Choose one of items that have warning flag
6716 * Calculate spell damages
6719 object_type *choose_warning_item(void)
6722 int choices[INVEN_TOTAL - INVEN_RARM];
6725 /* Paranoia -- Player has no warning ability */
6726 if (!p_ptr->warning) return NULL;
6728 /* Search Inventory */
6729 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6731 u32b flgs[TR_FLAG_SIZE];
6732 object_type *o_ptr = &inventory[i];
6734 object_flags(o_ptr, flgs);
6735 if (have_flag(flgs, TR_WARNING))
6737 choices[number] = i;
6742 /* Choice one of them */
6743 return number ? &inventory[choices[randint0(number)]] : NULL;
6747 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6748 * Calculate spell damages
6749 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6750 * @param typ 効果属性のID
6752 * @param max 算出した最大ダメージを返すポインタ
6755 static void spell_damcalc(monster_type *m_ptr, int typ, HIT_POINT dam, int *max)
6757 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6758 int rlev = r_ptr->level;
6759 bool ignore_wraith_form = FALSE;
6761 /* Vulnerability, resistance and immunity */
6765 if (p_ptr->immune_elec)
6768 ignore_wraith_form = TRUE;
6772 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6773 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6774 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6775 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6776 if (IS_OPPOSE_ELEC())
6777 dam = (dam + 2) / 3;
6782 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6783 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6787 if (p_ptr->immune_acid)
6790 ignore_wraith_form = TRUE;
6794 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6795 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6796 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6797 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6803 if (p_ptr->immune_cold)
6806 ignore_wraith_form = TRUE;
6810 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6811 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6812 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6813 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6818 if (p_ptr->immune_fire)
6821 ignore_wraith_form = TRUE;
6825 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6826 if (prace_is_(RACE_ENT)) dam += dam / 3;
6827 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6828 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6829 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6834 ignore_wraith_form = TRUE;
6838 if (!p_ptr->blind &&
6839 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6840 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6843 ignore_wraith_form = TRUE;
6848 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6849 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6850 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6853 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6854 * "dam *= 2;" for later "dam /= 2"
6856 if (p_ptr->wraith_form) dam *= 2;
6860 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6863 ignore_wraith_form = TRUE;
6865 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6869 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6873 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6877 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6881 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6885 if (prace_is_(RACE_SPECTRE))
6888 ignore_wraith_form = TRUE;
6890 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6894 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6898 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6902 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6906 if (p_ptr->levitation) dam = (dam * 2) / 3;
6910 if (p_ptr->resist_shard) dam /= 2;
6914 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6915 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6919 if (p_ptr->mimic_form)
6921 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6924 ignore_wraith_form = TRUE;
6929 switch (p_ptr->prace)
6938 ignore_wraith_form = TRUE;
6945 if (p_ptr->align > 10) dam /= 2;
6946 else if (p_ptr->align < -10) dam *= 2;
6950 if (p_ptr->align > 10) dam *= 2;
6954 case GF_BRAIN_SMASH:
6955 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6958 ignore_wraith_form = TRUE;
6966 if (100 + rlev / 2 <= p_ptr->skill_sav)
6969 ignore_wraith_form = TRUE;
6974 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6977 ignore_wraith_form = TRUE;
6982 if (p_ptr->wraith_form && !ignore_wraith_form)
6988 if (dam > *max) *max = dam;
6992 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6993 * Calculate spell damages
6994 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6995 * @param typ 効果属性のID
6996 * @param m_idx 魔法を行使するモンスターのID
6997 * @param max 算出した最大ダメージを返すポインタ
7000 void spell_damcalc_by_spellnum(int spell_num, int typ, MONSTER_IDX m_idx, int *max)
7002 monster_type *m_ptr = &m_list[m_idx];
7003 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
7004 spell_damcalc(m_ptr, typ, dam, max);
7008 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
7009 * Calculate blow damages
7010 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
7011 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
7012 * @return 算出された最大ダメージを返す。
7014 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7016 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7018 bool check_wraith_form = TRUE;
7020 if (blow_ptr->method != RBM_EXPLODE)
7022 int ac = p_ptr->ac + p_ptr->to_a;
7024 switch (blow_ptr->effect)
7028 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7029 dam = MAX(dam, tmp_dam * 2);
7035 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7039 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7041 check_wraith_form = FALSE;
7045 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7047 check_wraith_form = FALSE;
7051 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7053 check_wraith_form = FALSE;
7057 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7059 check_wraith_form = FALSE;
7064 check_wraith_form = FALSE;
7068 if (check_wraith_form && p_ptr->wraith_form)
7076 dam = (dam + 1) / 2;
7077 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7085 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7086 * Examine the grid (xx,yy) and warn the player if there are any danger
7087 * @param xx 危険性を調査するマスのX座標
7088 * @param yy 危険性を調査するマスのY座標
7089 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7091 bool process_warning(int xx, int yy)
7095 char o_name[MAX_NLEN];
7097 #define WARNING_AWARE_RANGE 12
7099 static int old_damage = 0;
7101 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7103 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7106 monster_type *m_ptr;
7107 monster_race *r_ptr;
7109 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7111 c_ptr = &cave[my][mx];
7113 if (!c_ptr->m_idx) continue;
7115 m_ptr = &m_list[c_ptr->m_idx];
7117 if (MON_CSLEEP(m_ptr)) continue;
7118 if (!is_hostile(m_ptr)) continue;
7120 r_ptr = &r_info[m_ptr->r_idx];
7122 /* Monster spells (only powerful ones)*/
7123 if (projectable(my, mx, yy, xx))
7125 u32b f4 = r_ptr->flags4;
7126 u32b f5 = r_ptr->a_ability_flags1;
7127 u32b f6 = r_ptr->a_ability_flags2;
7129 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7131 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7132 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7133 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7134 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7135 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7136 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7138 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7139 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7140 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7141 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7142 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7143 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7144 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7145 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7146 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7147 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7148 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7149 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7150 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7151 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7152 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7153 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7154 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7155 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7156 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7157 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7158 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7159 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7160 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7163 /* Monster melee attacks */
7164 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7166 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7170 for (m = 0; m < 4; m++)
7172 /* Skip non-attacks */
7173 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7175 /* Extract the attack info */
7176 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7177 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7179 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7183 /* Contribution from this monster */
7184 dam_max += dam_max0;
7188 /* Prevent excessive warning */
7189 if (dam_max > old_damage)
7191 old_damage = dam_max * 3 / 2;
7193 if (dam_max > p_ptr->chp / 2)
7195 object_type *o_ptr = choose_warning_item();
7198 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7200 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7201 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7204 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7207 else old_damage = old_damage / 2;
7209 c_ptr = &cave[yy][xx];
7210 if (((!easy_disarm && is_trap(c_ptr->feat))
7211 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7213 object_type *o_ptr = choose_warning_item();
7216 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7218 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7219 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7221 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7228 * @brief エッセンスの付加可能な武器や矢弾かを返す
7229 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7230 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7232 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7234 switch (o_ptr->tval)
7247 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7256 * エッセンス情報の構造体 / A structure for smithing
7259 int add; /* TR flag number or special essence id */
7260 cptr add_name; /* Name of this ability */
7261 ESSENCE_IDX type; /* Menu number */
7262 int essence; /* Index for carrying essences */
7263 int value; /* Needed value to add this ability */
7268 * エッセンス情報テーブル Smithing type data for Weapon smith
7271 static essence_type essence_info[] =
7273 {TR_STR, "腕力", 4, TR_STR, 20},
7274 {TR_INT, "知能", 4, TR_INT, 20},
7275 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7276 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7277 {TR_CON, "耐久力", 4, TR_CON, 20},
7278 {TR_CHR, "魅力", 4, TR_CHR, 20},
7279 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7280 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7281 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7282 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7283 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7284 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7285 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7286 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7287 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7288 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7289 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7290 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7291 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7292 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7293 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7294 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7295 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7296 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7297 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7298 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7299 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7300 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7301 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7302 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7303 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7304 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7305 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7306 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7307 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7308 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7309 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7310 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7311 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7312 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7313 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7314 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7315 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7316 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7317 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7318 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7319 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7320 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7321 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7322 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7323 {TR_SH_FIRE, "", 0, -2, 0},
7324 {TR_SH_ELEC, "", 0, -2, 0},
7325 {TR_SH_COLD, "", 0, -2, 0},
7326 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7327 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7328 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7329 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7330 {TR_LITE_2, "", 0, -2, 0},
7331 {TR_LITE_3, "", 0, -2, 0},
7332 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7333 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7334 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7335 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7336 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7338 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7339 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7340 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7341 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7342 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7343 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7344 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7345 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7346 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7347 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7348 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7349 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7350 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7351 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7352 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7353 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7354 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7355 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7357 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7358 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7359 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7360 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7361 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7362 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7363 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7364 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7366 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7367 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7368 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7369 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7370 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7371 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7372 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7373 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7374 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7375 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7376 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7377 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7379 {-1, NULL, 0, -1, 0}
7382 static essence_type essence_info[] =
7384 {TR_STR, "strength", 4, TR_STR, 20},
7385 {TR_INT, "intelligence", 4, TR_INT, 20},
7386 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7387 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7388 {TR_CON, "constitution", 4, TR_CON, 20},
7389 {TR_CHR, "charisma", 4, TR_CHR, 20},
7390 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7391 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7392 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7393 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7394 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7395 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7396 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7397 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7398 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7399 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7400 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7401 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7402 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7403 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7404 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7405 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7406 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7407 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7408 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7409 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7410 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7411 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7412 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7413 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7414 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7415 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7416 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7417 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7418 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7419 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7420 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7421 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7422 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7423 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7424 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7425 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7426 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7427 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7428 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7429 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7430 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7431 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7432 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7433 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7434 {TR_SH_FIRE, "", 0, -2, 0},
7435 {TR_SH_ELEC, "", 0, -2, 0},
7436 {TR_SH_COLD, "", 0, -2, 0},
7437 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7438 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7439 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7440 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7441 {TR_LITE_2, "", 0, -2, 0},
7442 {TR_LITE_3, "", 0, -2, 0},
7443 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7444 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7445 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7446 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7447 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7449 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7450 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7451 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7452 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7453 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7454 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7455 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7456 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7457 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7458 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7459 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7460 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7461 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7462 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7463 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7464 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7465 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7466 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7468 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7469 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7470 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7471 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7472 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7473 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7474 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7475 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7477 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7478 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7479 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7480 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7481 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7482 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7483 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7484 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7485 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7486 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7487 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7488 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7490 {-1, NULL, 0, -1, 0}
7496 * エッセンス名テーブル / Essense names for Weapon smith
7499 cptr essence_name[] =
7602 cptr essence_name[] =
7705 * @brief 所持しているエッセンス一覧を表示する
7708 static void display_essence(void)
7713 for (i = 1; i < 22; i++)
7717 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7718 "Essence Num Essence Num Essence Num "), 1, 8);
7719 for (i = 0; essence_name[i]; i++)
7721 if (!essence_name[i][0]) continue;
7722 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7725 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7735 static void drain_essence(void)
7737 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7741 bool observe = FALSE;
7742 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
7743 TIME_EFFECT old_timeout;
7744 BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7750 OBJECT_IDX next_o_idx;
7753 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7756 item_tester_hook = object_is_weapon_armour_ammo;
7757 item_tester_no_ryoute = TRUE;
7760 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7761 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7763 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7765 /* Get the item (in the pack) */
7768 o_ptr = &inventory[item];
7771 /* Get the item (on the floor) */
7774 o_ptr = &o_list[0 - item];
7777 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7779 char o_name[MAX_NLEN];
7780 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7781 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7784 p_ptr->energy_use = 100;
7786 object_flags(o_ptr, old_flgs);
7787 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7788 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7789 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7790 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7791 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7792 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7793 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7794 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7795 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7797 old_to_a = o_ptr->to_a;
7799 old_to_h = o_ptr->to_h;
7800 old_to_d = o_ptr->to_d;
7803 old_pval = o_ptr->pval;
7804 old_name2 = o_ptr->name2;
7805 old_timeout = o_ptr->timeout;
7806 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7807 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7808 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7809 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7810 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7811 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7812 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7813 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7814 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7815 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7816 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7817 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7818 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7819 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7820 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7821 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7822 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7823 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7824 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7828 next_o_idx = o_ptr->next_o_idx;
7829 marked = o_ptr->marked;
7830 weight = o_ptr->weight;
7831 number = o_ptr->number;
7833 object_prep(o_ptr, o_ptr->k_idx);
7837 o_ptr->next_o_idx=next_o_idx;
7838 o_ptr->marked=marked;
7839 o_ptr->number = number;
7840 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7841 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7842 o_ptr->ident |= (IDENT_MENTAL);
7843 object_aware(o_ptr);
7844 object_known(o_ptr);
7846 object_flags(o_ptr, new_flgs);
7848 for (i = 0; essence_info[i].add_name; i++)
7850 essence_type *es_ptr = &essence_info[i];
7851 PARAMETER_VALUE pval = 0;
7853 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7854 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7856 if (es_ptr->add < TR_FLAG_MAX &&
7857 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7858 have_flag(old_flgs, es_ptr->add))
7862 drain_value[es_ptr->essence] += 10 * pval;
7864 else if (es_ptr->essence != -2)
7866 drain_value[es_ptr->essence] += 10;
7868 else if (es_ptr->add == TR_SH_FIRE)
7870 drain_value[TR_BRAND_FIRE] += 10;
7871 drain_value[TR_RES_FIRE] += 10;
7873 else if (es_ptr->add == TR_SH_ELEC)
7875 drain_value[TR_BRAND_ELEC] += 10;
7876 drain_value[TR_RES_ELEC] += 10;
7878 else if (es_ptr->add == TR_SH_COLD)
7880 drain_value[TR_BRAND_COLD] += 10;
7881 drain_value[TR_RES_COLD] += 10;
7883 else if (es_ptr->add == TR_LITE_2)
7885 drain_value[TR_LITE_1] += 20;
7887 else if (es_ptr->add == TR_LITE_3)
7889 drain_value[TR_LITE_1] += 30;
7894 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7896 drain_value[TR_INT] += 5;
7897 drain_value[TR_WIS] += 5;
7899 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7901 drain_value[TR_BRAND_POIS] += 5;
7902 drain_value[TR_BRAND_ACID] += 5;
7903 drain_value[TR_BRAND_ELEC] += 5;
7904 drain_value[TR_BRAND_FIRE] += 5;
7905 drain_value[TR_BRAND_COLD] += 5;
7907 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7909 drain_value[TR_INT] += 10;
7911 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7913 drain_value[TR_STR] += 10;
7915 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7917 drain_value[TR_DEX] += 10;
7919 if (old_name2 == EGO_2WEAPON)
7921 drain_value[TR_DEX] += 20;
7923 if (object_is_weapon_ammo(o_ptr))
7925 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7927 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7929 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7930 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7931 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7932 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7934 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7936 drain_value[i] *= number;
7937 drain_value[i] = drain_value[i] * dec / 4;
7938 drain_value[i] = MAX(drain_value[i], 0);
7939 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7947 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7951 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7953 for (i = 0; essence_name[i]; i++)
7955 if (!essence_name[i][0]) continue;
7956 if (!drain_value[i]) continue;
7958 p_ptr->magic_num1[i] += drain_value[i];
7959 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7961 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7965 /* Apply autodestroy/inscription to the drained item */
7966 autopick_alter_item(item, TRUE);
7968 /* Combine the pack */
7969 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7972 p_ptr->window |= (PW_INVEN);
7976 * @brief 付加するエッセンスの大別を選択する
7977 * @return 選んだエッセンスの大別ID
7979 static COMMAND_CODE choose_essence(void)
7981 COMMAND_CODE mode = 0;
7983 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
7986 cptr menu_name[] = {
7996 cptr menu_name[] = {
8006 const COMMAND_CODE mode_max = 7;
8009 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
8012 #endif /* ALLOW_REPEAT */
8021 for (i = 0; i < mode_max; i++)
8023 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8024 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8026 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8027 prt("Choose from menu.", 0, 0);
8046 menu_line += mode_max - 1;
8055 if (menu_line > mode_max) menu_line -= mode_max;
8066 for (i = 0; i < mode_max; i++)
8067 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8069 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8075 if (isupper(choice)) choice = (char)tolower(choice);
8077 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8078 mode = (int)choice - 'a' + 1;
8085 #endif /* ALLOW_REPEAT */
8090 * @brief エッセンスを実際に付加する
8091 * @param mode エッセンスの大別ID
8094 static void add_essence(ESSENCE_IDX mode)
8106 char o_name[MAX_NLEN];
8108 essence_type *es_ptr;
8110 int menu_line = (use_menu ? 1 : 0);
8112 for (i = 0; essence_info[i].add_name; i++)
8114 es_ptr = &essence_info[i];
8116 if (es_ptr->type != mode) continue;
8121 if (!repeat_pull(&i) || i<0 || i>=max_num)
8123 #endif /* ALLOW_REPEAT */
8126 /* Nothing chosen yet */
8132 /* Build a prompt */
8133 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8134 if (use_menu) screen_save();
8136 /* Get a spell from the user */
8138 choice = (always_show_list || use_menu) ? ESCAPE:1;
8141 bool able[22] = {0};
8142 if( choice==ESCAPE ) choice = ' ';
8143 else if( !get_com(out_val, &choice, FALSE) )break;
8145 if (use_menu && choice != ' ')
8159 menu_line += (max_num-1);
8182 menu_line = max_num;
8196 if (menu_line > max_num) menu_line -= max_num;
8198 /* Request redraw */
8199 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8202 if (!redraw || use_menu)
8206 char dummy[80], dummy2[80];
8214 /* Save the screen */
8215 if (!use_menu) screen_save();
8217 for (y = 1; y < 24; y++)
8220 /* Print header(s) */
8222 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8225 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8228 for (ctr = 0; ctr < max_num; ctr++)
8230 es_ptr = &essence_info[num[ctr]];
8234 if (ctr == (menu_line-1))
8235 strcpy(dummy, _("》 ", "> "));
8236 else strcpy(dummy, " ");
8239 /* letter/number for power selection */
8242 sprintf(dummy, "%c) ",I2A(ctr));
8245 strcat(dummy, es_ptr->add_name);
8250 if (es_ptr->essence != -1)
8252 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8253 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8259 case ESSENCE_SH_FIRE:
8260 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8261 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8262 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8264 case ESSENCE_SH_ELEC:
8265 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8266 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8267 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8269 case ESSENCE_SH_COLD:
8270 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8271 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8272 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8274 case ESSENCE_RESISTANCE:
8275 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8276 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8277 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8278 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8279 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8281 case ESSENCE_SUSTAIN:
8282 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8283 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8284 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8285 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8286 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8291 if (!able[ctr]) col = TERM_RED;
8293 if (es_ptr->essence != -1)
8295 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8299 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8302 c_prt(col, dummy2, ctr+2, x);
8312 /* Restore the screen */
8323 ask = (isupper(choice));
8326 if (ask) choice = (char)tolower(choice);
8328 /* Extract request */
8329 i = (islower(choice) ? A2I(choice) : -1);
8332 /* Totally Illegal */
8333 if ((i < 0) || (i >= max_num) || !able[i])
8345 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8347 /* Belay that order */
8348 if (!get_check(tmp_val)) continue;
8355 /* Restore the screen */
8356 if (redraw) screen_load();
8363 #endif /* ALLOW_REPEAT */
8365 es_ptr = &essence_info[num[i]];
8367 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8368 item_tester_tval = TV_GLOVES;
8369 else if (mode == 1 || mode == 5)
8370 item_tester_hook = item_tester_hook_melee_ammo;
8371 else if (es_ptr->add == ESSENCE_ATTACK)
8372 item_tester_hook = object_allow_enchant_weapon;
8373 else if (es_ptr->add == ESSENCE_AC)
8374 item_tester_hook = object_is_armour;
8376 item_tester_hook = object_is_weapon_armour_ammo;
8377 item_tester_no_ryoute = TRUE;
8380 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8381 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8383 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8385 /* Get the item (in the pack) */
8388 o_ptr = &inventory[item];
8391 /* Get the item (on the floor) */
8394 o_ptr = &o_list[0 - item];
8397 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8399 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8403 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8405 use_essence = es_ptr->value;
8406 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8407 if (o_ptr->number > 1)
8409 use_essence *= o_ptr->number;
8410 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8413 if (es_ptr->essence != -1)
8415 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8417 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8420 if (is_pval_flag(es_ptr->add))
8422 if (o_ptr->pval < 0)
8424 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8427 else if (es_ptr->add == TR_BLOWS)
8429 if (o_ptr->pval > 1)
8431 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8435 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8437 else if (o_ptr->pval > 0)
8439 use_essence *= o_ptr->pval;
8440 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8446 PARAMETER_VALUE pval;
8447 PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8449 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8450 strcpy(tmp_val, "1");
8452 if (!get_string(tmp, tmp_val, 1)) return;
8453 pval = (PARAMETER_VALUE)atoi(tmp_val);
8454 if (pval > limit) pval = limit;
8455 else if (pval < 1) pval = 1;
8456 o_ptr->pval += pval;
8457 use_essence *= pval;
8458 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8461 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8463 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8467 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8474 strcpy(tmp_val, "1");
8475 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8476 val = atoi(tmp_val);
8477 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8478 else if (val < 1) val = 1;
8480 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8481 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8483 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8486 get_to_h = ((val+1)/2+randint0(val/2+1));
8487 get_to_d = ((val+1)/2+randint0(val/2+1));
8488 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8489 o_ptr->to_h += get_to_h;
8490 o_ptr->to_d += get_to_d;
8492 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8493 if (es_ptr->add == ESSENCE_ATTACK)
8495 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8497 msg_print(_("改良に失敗した。", "You failed to enchant."));
8498 p_ptr->energy_use = 100;
8503 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8504 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8507 else if (es_ptr->add == ESSENCE_AC)
8509 if (o_ptr->to_a >= p_ptr->lev/5+5)
8511 msg_print(_("改良に失敗した。", "You failed to enchant."));
8512 p_ptr->energy_use = 100;
8517 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8522 o_ptr->xtra3 = es_ptr->add + 1;
8527 bool success = TRUE;
8531 case ESSENCE_SH_FIRE:
8532 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8537 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8538 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8540 case ESSENCE_SH_ELEC:
8541 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8546 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8547 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8549 case ESSENCE_SH_COLD:
8550 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8555 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8556 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8558 case ESSENCE_RESISTANCE:
8559 case ESSENCE_SUSTAIN:
8560 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))
8565 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8566 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8567 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8568 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8573 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8576 if (es_ptr->add == ESSENCE_SUSTAIN)
8578 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8579 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8580 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8581 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8585 o_ptr->xtra3 = es_ptr->add + 1;
8589 p_ptr->energy_use = 100;
8592 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8594 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8597 /* Combine the pack */
8598 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8601 p_ptr->window |= (PW_INVEN);
8608 static void erase_essence(void)
8613 char o_name[MAX_NLEN];
8614 BIT_FLAGS flgs[TR_FLAG_SIZE];
8616 item_tester_hook = object_is_smith;
8619 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8620 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8622 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8624 /* Get the item (in the pack) */
8627 o_ptr = &inventory[item];
8630 /* Get the item (on the floor) */
8633 o_ptr = &o_list[0 - item];
8636 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8637 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8639 p_ptr->energy_use = 100;
8641 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8643 o_ptr->to_h -= (o_ptr->xtra4>>8);
8644 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8646 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8647 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8650 object_flags(o_ptr, flgs);
8651 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8652 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8654 /* Combine the pack */
8655 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8658 p_ptr->window |= (PW_INVEN);
8662 * @brief 鍛冶コマンドのメインルーチン
8663 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8666 void do_cmd_kaji(bool only_browse)
8668 COMMAND_CODE mode = 0;
8671 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
8675 if (p_ptr->confused)
8677 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8682 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8687 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8693 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8695 #endif /* ALLOW_REPEAT */
8697 if (only_browse) screen_save();
8699 if (!only_browse) screen_save();
8705 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8706 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8707 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8708 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8709 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8710 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8712 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8713 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8714 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8715 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8716 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8717 prt(format("Choose command from menu."), 0, 0);
8744 if (menu_line > 5) menu_line -= 5;
8753 prt(" a) エッセンス一覧", 2, 14);
8754 prt(" b) エッセンス抽出", 3, 14);
8755 prt(" c) エッセンス消去", 4, 14);
8756 prt(" d) エッセンス付加", 5, 14);
8757 prt(" e) 武器/防具強化", 6, 14);
8758 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8760 prt(" a) List essences", 2, 14);
8761 prt(" b) Extract essence", 3, 14);
8762 prt(" c) Remove essence", 4, 14);
8763 prt(" d) Add essence", 5, 14);
8764 prt(" e) Enchant weapon/armor", 6, 14);
8765 if (!get_com("Command :", &choice, TRUE))
8802 /* Clear lines, position cursor (really should use strlen here) */
8803 Term_erase(14, 21, 255);
8804 Term_erase(14, 20, 255);
8805 Term_erase(14, 19, 255);
8806 Term_erase(14, 18, 255);
8807 Term_erase(14, 17, 255);
8808 Term_erase(14, 16, 255);
8810 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8811 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8813 prt(&temp[j], line, 15);
8818 if (!only_browse) screen_load();
8819 } while (only_browse);
8823 #endif /* ALLOW_REPEAT */
8827 case 1: display_essence();break;
8828 case 2: drain_essence();break;
8829 case 3: erase_essence();break;
8831 mode = choose_essence();
8836 case 5: add_essence(10);break;
8842 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8843 * Torches have special abilities when they are flaming.
8844 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8845 * @param flgs 特別に追加するフラグを返す参照ポインタ
8848 void torch_flags(object_type *o_ptr, u32b *flgs)
8850 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8852 if (o_ptr->xtra4 > 0)
8854 add_flag(flgs, TR_BRAND_FIRE);
8855 add_flag(flgs, TR_KILL_UNDEAD);
8856 add_flag(flgs, TR_THROW);
8862 * @brief 投擲時たいまつにダイスを与える。
8863 * Torches have special abilities when they are flaming.
8864 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8865 * @param dd 特別なダイス数を返す参照ポインタ
8866 * @param ds 特別なダイス面数を返す参照ポインタ
8869 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8871 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8873 if (o_ptr->xtra4 > 0)
8882 * @brief 投擲時命中したたいまつの寿命を縮める。
8883 * Torches have special abilities when they are flaming.
8884 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8887 void torch_lost_fuel(object_type *o_ptr)
8889 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8891 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8892 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;