3 * @brief オブジェクトの実装 / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
16 static cptr const kaji_tips[5] =
19 "現在持っているエッセンスの一覧を表示する。",
20 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
21 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
22 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
23 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
25 "Display essences you have.",
26 "Extract essences from an item. The item become non magical.",
27 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
28 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
29 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
34 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
35 * @param o_idx 削除対象のオブジェクト構造体ポインタ
38 void excise_object_idx(int o_idx)
42 s16b this_o_idx, next_o_idx = 0;
48 j_ptr = &o_list[o_idx];
51 if (j_ptr->held_m_idx)
56 m_ptr = &m_list[j_ptr->held_m_idx];
58 /* Scan all objects in the grid */
59 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
64 o_ptr = &o_list[this_o_idx];
66 /* Acquire next object */
67 next_o_idx = o_ptr->next_o_idx;
70 if (this_o_idx == o_idx)
75 /* Remove from list */
76 m_ptr->hold_o_idx = next_o_idx;
85 k_ptr = &o_list[prev_o_idx];
87 /* Remove from list */
88 k_ptr->next_o_idx = next_o_idx;
91 /* Forget next pointer */
92 o_ptr->next_o_idx = 0;
99 prev_o_idx = this_o_idx;
114 /* Scan all objects in the grid */
115 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
120 o_ptr = &o_list[this_o_idx];
122 /* Acquire next object */
123 next_o_idx = o_ptr->next_o_idx;
126 if (this_o_idx == o_idx)
131 /* Remove from list */
132 c_ptr->o_idx = next_o_idx;
140 /* Previous object */
141 k_ptr = &o_list[prev_o_idx];
143 /* Remove from list */
144 k_ptr->next_o_idx = next_o_idx;
147 /* Forget next pointer */
148 o_ptr->next_o_idx = 0;
154 /* Save prev_o_idx */
155 prev_o_idx = this_o_idx;
161 * @brief オブジェクトを削除する /
162 * Delete a dungeon object
163 * @param o_idx 削除対象のオブジェクト構造体ポインタ
166 * Handle "stacks" of objects correctly.
168 void delete_object_idx(int o_idx)
173 excise_object_idx(o_idx);
176 j_ptr = &o_list[o_idx];
179 if (!(j_ptr->held_m_idx))
191 /* Wipe the object */
200 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
201 * Delete a dungeon object
202 * @param y 削除したフロアマスのY座標
203 * @param x 削除したフロアマスのX座標
206 void delete_object(int y, int x)
210 s16b this_o_idx, next_o_idx = 0;
213 /* Refuse "illegal" locations */
214 if (!in_bounds(y, x)) return;
220 /* Scan all objects in the grid */
221 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
226 o_ptr = &o_list[this_o_idx];
228 /* Acquire next object */
229 next_o_idx = o_ptr->next_o_idx;
231 /* Wipe the object */
238 /* Objects are gone */
247 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
248 * Move an object from index i1 to index i2 in the object list
249 * @param i1 整理したい配列の始点
250 * @param i2 整理したい配列の終点
253 static void compact_objects_aux(IDX i1, IDX i2)
260 if (i1 == i2) return;
264 for (i = 1; i < o_max; i++)
269 /* Skip "dead" objects */
270 if (!o_ptr->k_idx) continue;
272 /* Repair "next" pointers */
273 if (o_ptr->next_o_idx == i1)
276 o_ptr->next_o_idx = i2;
286 if (o_ptr->held_m_idx)
290 /* Acquire monster */
291 m_ptr = &m_list[o_ptr->held_m_idx];
294 if (m_ptr->hold_o_idx == i1)
297 m_ptr->hold_o_idx = i2;
306 /* Acquire location */
314 if (c_ptr->o_idx == i1)
323 o_list[i2] = o_list[i1];
331 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
332 * Compact and Reorder the object list.
333 * @param size 最低でも減らしたいオブジェクト数の水準
337 * This function can be very dangerous, use with caution!\n
339 * When actually "compacting" objects, we base the saving throw on a\n
340 * combination of object level, distance from player, and current\n
343 * After "compacting" (if needed), we "reorder" the objects into a more\n
344 * compact order, and we reset the allocation info, and the "live" array.\n
346 void compact_objects(int size)
348 int i, y, x, num, cnt;
349 int cur_lev, cur_dis, chance;
357 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
360 p_ptr->redraw |= (PR_MAP);
363 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
367 /* Compact at least 'size' objects */
368 for (num = 0, cnt = 1; num < size; cnt++)
370 /* Get more vicious each iteration */
373 /* Get closer each iteration */
374 cur_dis = 5 * (20 - cnt);
376 /* Examine the objects */
377 for (i = 1; i < o_max; i++)
381 /* Skip dead objects */
382 if (!o_ptr->k_idx) continue;
384 /* Hack -- High level objects start out "immune" */
385 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
388 if (o_ptr->held_m_idx)
392 /* Acquire monster */
393 m_ptr = &m_list[o_ptr->held_m_idx];
395 /* Get the location */
399 /* Monsters protect their objects */
400 if (randint0(100) < 90) continue;
406 /* Get the location */
411 /* Nearby objects start out "immune" */
412 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
417 /* Hack -- only compact artifacts in emergencies */
418 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
419 (cnt < 1000)) chance = 100;
421 /* Apply the saving throw */
422 if (randint0(100) < chance) continue;
424 /* Delete the object */
425 delete_object_idx(i);
433 /* Excise dead objects (backwards!) */
434 for (i = o_max - 1; i >= 1; i--)
438 /* Skip real objects */
439 if (o_ptr->k_idx) continue;
441 /* Move last object into open hole */
442 compact_objects_aux(o_max - 1, i);
444 /* Compress "o_max" */
451 * @brief グローバルオブジェクト配列を初期化する /
452 * Delete all the items when player leaves the level
453 * @note we do NOT visually reflect these (irrelevant) changes
455 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
456 * and the "m_ptr->next_o_idx" field for every monster, since
457 * we know we are clearing every object. Technically, we only
458 * clear those fields for grids/monsters containing objects,
459 * and we clear it once for every such object.
462 void wipe_o_list(void)
466 /* Delete the existing objects */
467 for (i = 1; i < o_max; i++)
469 object_type *o_ptr = &o_list[i];
471 /* Skip dead objects */
472 if (!o_ptr->k_idx) continue;
474 /* Mega-Hack -- preserve artifacts */
475 if (!character_dungeon || preserve_mode)
477 /* Hack -- Preserve unknown artifacts */
478 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
480 /* Mega-Hack -- Preserve the artifact */
481 a_info[o_ptr->name1].cur_num = 0;
486 if (o_ptr->held_m_idx)
491 m_ptr = &m_list[o_ptr->held_m_idx];
493 /* Hack -- see above */
494 m_ptr->hold_o_idx = 0;
502 /* Access location */
509 /* Hack -- see above */
513 /* Wipe the object */
526 * @brief グローバルオブジェクト配列から空きを取得する /
527 * Acquires and returns the index of a "free" object.
528 * @return 開いているオブジェクト要素のID
530 * This routine should almost never fail, but in case it does,
531 * we must be sure to handle "failure" of this routine.
538 /* Initial allocation */
539 if (o_max < max_o_idx)
544 /* Expand object array */
550 /* Use this object */
555 /* Recycle dead objects */
556 for (i = 1; i < o_max; i++)
563 /* Skip live objects */
564 if (o_ptr->k_idx) continue;
569 /* Use this object */
574 /* Warn the player (except during dungeon creation) */
575 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
583 * @brief オブジェクト生成テーブルに生成制約を加える /
584 * Apply a "object restriction function" to the "object allocation table"
586 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
588 static errr get_obj_num_prep(void)
593 alloc_entry *table = alloc_kind_table;
595 /* Scan the allocation table */
596 for (i = 0; i < alloc_kind_size; i++)
598 /* Accept objects which pass the restriction, if any */
599 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
601 /* Accept this object */
602 table[i].prob2 = table[i].prob1;
605 /* Do not use this object */
608 /* Decline this object */
619 * @brief オブジェクト生成テーブルからアイテムを取得する /
620 * Choose an object kind that seems "appropriate" to the given level
622 * @return 選ばれたオブジェクトベースID
624 * This function uses the "prob2" field of the "object allocation table",\n
625 * and various local information, to calculate the "prob3" field of the\n
626 * same table, which is then used to choose an "appropriate" object, in\n
627 * a relatively efficient manner.\n
629 * It is (slightly) more likely to acquire an object of the given level\n
630 * than one of a lower level. This is done by choosing several objects\n
631 * appropriate to the given level and keeping the "hardest" one.\n
633 * Note that if no objects are "appropriate", then this function will\n
634 * fail, and return zero, but this should *almost* never happen.\n
636 s16b get_obj_num(int level)
642 alloc_entry *table = alloc_kind_table;
644 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
647 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
649 /* Occasional "boost" */
650 if (one_in_(GREAT_OBJ))
652 /* What a bizarre calculation */
653 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
660 /* Process probabilities */
661 for (i = 0; i < alloc_kind_size; i++)
663 /* Objects are sorted by depth */
664 if (table[i].level > level) break;
669 /* Access the index */
670 k_idx = table[i].index;
672 /* Access the actual kind */
673 k_ptr = &k_info[k_idx];
675 /* Hack -- prevent embedded chests */
676 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
679 table[i].prob3 = table[i].prob2;
682 total += table[i].prob3;
685 /* No legal objects */
686 if (total <= 0) return (0);
690 value = randint0(total);
692 /* Find the object */
693 for (i = 0; i < alloc_kind_size; i++)
695 /* Found the entry */
696 if (value < table[i].prob3) break;
699 value = value - table[i].prob3;
706 /* Try for a "better" object once (50%) or twice (10%) */
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;
725 /* Keep the "best" one */
726 if (table[i].level < table[j].level) i = j;
729 /* Try for a "better" object 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;
754 return (table[i].index);
759 * @brief オブジェクトを鑑定済にする /
760 * Known is true when the "attributes" of an object are "known".
761 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
763 * These include tohit, todam, toac, cost, and pval (charges).\n
765 * Note that "knowing" an object gives you everything that an "awareness"\n
766 * gives you, and much more. In fact, the player is always "aware" of any\n
767 * item of which he has full "knowledge".\n
769 * But having full knowledge of, say, one "wand of wonder", does not, by\n
770 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
771 * It happens that most "identify" routines (including "buying from a shop")\n
772 * will make the player "aware" of the object as well as fully "know" it.\n
774 * This routine also removes any inscriptions generated by "feelings".\n
776 void object_known(object_type *o_ptr)
778 /* Remove "default inscriptions" */
779 o_ptr->feeling = FEEL_NONE;
781 /* Clear the "Felt" info */
782 o_ptr->ident &= ~(IDENT_SENSE);
784 /* Clear the "Empty" info */
785 o_ptr->ident &= ~(IDENT_EMPTY);
787 /* Now we know about the item */
788 o_ptr->ident |= (IDENT_KNOWN);
792 * @brief オブジェクトを*鑑定*済にする /
793 * The player is now aware of the effects of the given object.
794 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
797 void object_aware(object_type *o_ptr)
799 bool mihanmei = !object_is_aware(o_ptr);
801 /* Fully aware of the effects */
802 k_info[o_ptr->k_idx].aware = TRUE;
804 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
805 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
809 char o_name[MAX_NLEN];
812 object_copy(q_ptr, o_ptr);
815 object_desc(o_name, q_ptr, OD_NAME_ONLY);
817 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
823 * @brief オブジェクトを試行済にする /
824 * Something has been "sampled"
825 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
828 void object_tried(object_type *o_ptr)
830 /* Mark it as tried (even if "aware") */
831 k_info[o_ptr->k_idx].tried = TRUE;
836 * @brief 未鑑定なベースアイテムの基本価格を返す /
837 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
838 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
839 * @return オブジェクトの未鑑定価格
841 static s32b object_value_base(object_type *o_ptr)
843 /* Aware item -- use template cost */
844 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
846 /* Analyze the type */
851 case TV_FOOD: return (5L);
853 /* Un-aware Potions */
854 case TV_POTION: return (20L);
856 /* Un-aware Scrolls */
857 case TV_SCROLL: return (20L);
859 /* Un-aware Staffs */
860 case TV_STAFF: return (70L);
863 case TV_WAND: return (50L);
866 case TV_ROD: return (90L);
869 case TV_RING: return (45L);
871 /* Un-aware Amulets */
872 case TV_AMULET: return (45L);
874 /* Figurines, relative to monster level */
877 int level = r_info[o_ptr->pval].level;
878 if (level < 20) return level*50L;
879 else if (level < 30) return 1000+(level-20)*150L;
880 else if (level < 40) return 2500+(level-30)*350L;
881 else if (level < 50) return 6000+(level-40)*800L;
882 else return 14000+(level-50)*2000L;
886 if (!o_ptr->pval) return 1000L;
887 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
890 /* Paranoia -- Oops */
896 * @brief オブジェクトのフラグ類から価格を算出する /
897 * Return the value of the flags the object has...
898 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
899 * @param plusses フラグに与える価格の基本重み
900 * @return オブジェクトのフラグ価格
902 s32b flag_cost(object_type *o_ptr, int plusses)
905 u32b flgs[TR_FLAG_SIZE];
909 object_kind *k_ptr = &k_info[o_ptr->k_idx];
911 object_flags(o_ptr, flgs);
914 * Exclude fixed flags of the base item.
915 * pval bonuses of base item will be treated later.
917 for (i = 0; i < TR_FLAG_SIZE; i++)
918 flgs[i] &= ~(k_ptr->flags[i]);
920 /* Exclude fixed flags of the fixed artifact. */
921 if (object_is_fixed_artifact(o_ptr))
923 artifact_type *a_ptr = &a_info[o_ptr->name1];
925 for (i = 0; i < TR_FLAG_SIZE; i++)
926 flgs[i] &= ~(a_ptr->flags[i]);
929 /* Exclude fixed flags of the ego-item. */
930 else if (object_is_ego(o_ptr))
932 ego_item_type *e_ptr = &e_info[o_ptr->name2];
934 for (i = 0; i < TR_FLAG_SIZE; i++)
935 flgs[i] &= ~(e_ptr->flags[i]);
940 * Calucurate values of remaining flags
942 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
943 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
944 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
945 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
946 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
947 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
948 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
949 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
950 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
951 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
952 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
953 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
954 total += (10000 + (2500 * plusses));
955 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
956 total += (10000 + (2500 * plusses));
960 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
961 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
962 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
963 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
964 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
965 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
966 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
967 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
968 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
969 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
970 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
971 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
972 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
973 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
974 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
975 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
976 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
977 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
978 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
979 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
980 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
982 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
983 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
984 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
985 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
986 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
987 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
988 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
989 total += (tmp_cost * count);
991 if (have_flag(flgs, TR_SUST_STR)) total += 850;
992 if (have_flag(flgs, TR_SUST_INT)) total += 850;
993 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
994 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
995 if (have_flag(flgs, TR_SUST_CON)) total += 850;
996 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
997 if (have_flag(flgs, TR_RIDING)) total += 0;
998 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
999 if (have_flag(flgs, TR_THROW)) total += 5000;
1000 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1001 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1005 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1006 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1007 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1008 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1009 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1010 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1011 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1012 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1013 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1014 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1015 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1016 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1017 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1018 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1019 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1020 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1021 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1022 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1023 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1024 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1025 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1026 total += (tmp_cost * count);
1028 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1029 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1030 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1031 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1032 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1033 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1034 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1035 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1036 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1037 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1038 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1039 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1040 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1041 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1042 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1043 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1044 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1045 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1046 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1047 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1048 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1049 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1050 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1051 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1052 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1053 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1054 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1055 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1056 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1057 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1058 if (have_flag(flgs, TR_REGEN)) total += 2500;
1059 if (have_flag(flgs, TR_WARNING)) total += 2000;
1060 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1061 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1062 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1063 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1064 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1065 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1066 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1067 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1068 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1069 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1070 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1071 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1072 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1073 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1074 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1075 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1076 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1077 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1078 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1079 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1080 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1081 if (have_flag(flgs, TR_TELEPORT))
1083 if (object_is_cursed(o_ptr))
1088 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1089 if (have_flag(flgs, TR_BLESSED)) total += 750;
1090 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1091 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1092 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1093 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1094 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1096 /* Also, give some extra for activatable powers... */
1097 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1099 const activation_type* const act_ptr = find_activation_info(o_ptr);
1101 total += act_ptr->value;
1110 * @brief オブジェクトの真の価格を算出する /
1111 * Return the value of the flags the object has...
1112 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1113 * @return オブジェクトの本価格
1115 * Return the "real" price of a "known" item, not including discounts\n
1117 * Wand and staffs get cost for each charge\n
1119 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1121 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1123 * Missiles are only worth 5 gold per bonus point, since they\n
1124 * usually appear in groups of 20, and we want the player to get\n
1125 * the same amount of cash for any "equivalent" item. Note that\n
1126 * missiles never have any of the "pval" flags, and in fact, they\n
1127 * only have a few of the available flags, primarily of the "slay"\n
1128 * and "brand" and "ignore" variety.\n
1130 * Armor with a negative armor bonus is worthless.\n
1131 * Weapons with negative hit+damage bonuses are worthless.\n
1133 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1135 s32b object_value_real(object_type *o_ptr)
1139 u32b flgs[TR_FLAG_SIZE];
1141 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1144 /* Hack -- "worthless" items */
1145 if (!k_info[o_ptr->k_idx].cost) return (0L);
1148 value = k_info[o_ptr->k_idx].cost;
1150 /* Extract some flags */
1151 object_flags(o_ptr, flgs);
1154 if (object_is_fixed_artifact(o_ptr))
1156 artifact_type *a_ptr = &a_info[o_ptr->name1];
1158 /* Hack -- "worthless" artifacts */
1159 if (!a_ptr->cost) return (0L);
1161 /* Hack -- Use the artifact cost instead */
1162 value = a_ptr->cost;
1163 value += flag_cost(o_ptr, o_ptr->pval);
1165 /* Don't add pval bonuses etc. */
1170 else if (object_is_ego(o_ptr))
1172 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1174 /* Hack -- "worthless" ego-items */
1175 if (!e_ptr->cost) return (0L);
1177 /* Hack -- Reward the ego-item with a bonus */
1178 value += e_ptr->cost;
1179 value += flag_cost(o_ptr, o_ptr->pval);
1187 for (i = 0; i < TR_FLAG_SIZE; i++)
1188 if (o_ptr->art_flags[i]) flag = TRUE;
1190 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1193 /* Analyze pval bonus for normal object */
1194 switch (o_ptr->tval)
1217 if (!o_ptr->pval) break;
1219 /* Hack -- Negative "pval" is always bad */
1220 if (o_ptr->pval < 0) return (0L);
1222 /* Give credit for stat bonuses */
1223 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1224 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1225 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1226 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1227 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1228 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1230 /* Give credit for stealth and searching */
1231 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1232 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1233 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1235 /* Give credit for infra-vision and tunneling */
1236 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1237 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1239 /* Give credit for extra attacks */
1240 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1242 /* Give credit for speed bonus */
1243 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1249 /* Analyze the item */
1250 switch (o_ptr->tval)
1255 /* Pay extra for charges, depending on standard number of
1256 * charges. Handle new-style wands correctly. -LM-
1258 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1265 /* Pay extra for charges, depending on standard number of
1268 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1278 /* Hack -- negative bonuses are bad */
1279 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1281 /* Give credit for bonuses */
1282 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1299 /* Hack -- negative armor bonus */
1300 if (o_ptr->to_a < 0) return (0L);
1302 /* Give credit for bonuses */
1303 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1316 /* Hack -- negative hit/damage bonuses */
1317 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1319 /* Factor in the bonuses */
1320 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1322 /* Hack -- Factor in extra damage dice and sides */
1323 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1324 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1335 /* Hack -- negative hit/damage bonuses */
1336 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1338 /* Factor in the bonuses */
1339 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1341 /* Hack -- Factor in extra damage dice and sides */
1342 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1343 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1349 /* Figurines, relative to monster level */
1352 int level = r_info[o_ptr->pval].level;
1353 if (level < 20) value = level*50L;
1354 else if (level < 30) value = 1000+(level-20)*150L;
1355 else if (level < 40) value = 2500+(level-30)*350L;
1356 else if (level < 50) value = 6000+(level-40)*800L;
1357 else value = 14000+(level-50)*2000L;
1363 if (!o_ptr->pval) value = 1000L;
1364 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1370 if (!o_ptr->pval) value = 0L;
1375 /* Worthless object */
1376 if (value < 0) return 0L;
1378 /* Return the value */
1384 * @brief オブジェクト価格算出のメインルーチン /
1385 * Return the price of an item including plusses (and charges)
1386 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1387 * @return オブジェクトの判明している現価格
1389 * This function returns the "value" of the given item (qty one)\n
1391 * Never notice "unknown" bonuses or properties, including "curses",\n
1392 * since that would give the player information he did not have.\n
1394 * Note that discounted items stay discounted forever, even if\n
1395 * the discount is "forgotten" by the player via memory loss.\n
1397 s32b object_value(object_type *o_ptr)
1402 /* Unknown items -- acquire a base value */
1403 if (object_is_known(o_ptr))
1405 /* Broken items -- worthless */
1406 if (object_is_broken(o_ptr)) return (0L);
1408 /* Cursed items -- worthless */
1409 if (object_is_cursed(o_ptr)) return (0L);
1411 /* Real value (see above) */
1412 value = object_value_real(o_ptr);
1415 /* Known items -- acquire the actual value */
1418 /* Hack -- Felt broken items */
1419 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1421 /* Hack -- Felt cursed items */
1422 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1424 /* Base value (see above) */
1425 value = object_value_base(o_ptr);
1429 /* Apply discount (if any) */
1430 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1433 /* Return the final value */
1440 * @brief 破壊可能なアイテムかを返す /
1441 * Determines whether an object can be destroyed, and makes fake inscription.
1442 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1443 * @return オブジェクトが破壊可能ならばTRUEを返す
1445 bool can_player_destroy_object(object_type *o_ptr)
1447 /* Artifacts cannot be destroyed */
1448 if (!object_is_artifact(o_ptr)) return TRUE;
1450 /* If object is unidentified, makes fake inscription */
1451 if (!object_is_known(o_ptr))
1453 byte feel = FEEL_SPECIAL;
1455 /* Hack -- Handle icky artifacts */
1456 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1458 /* Hack -- inscribe the artifact */
1459 o_ptr->feeling = feel;
1461 /* We have "felt" it (again) */
1462 o_ptr->ident |= (IDENT_SENSE);
1464 /* Combine the pack */
1465 p_ptr->notice |= (PN_COMBINE);
1468 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1474 /* Identified artifact -- Nothing to do */
1480 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1481 * Distribute charges of rods or wands.
1482 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1483 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1484 * @param amt 分割したい回数量 number of items that are transfered
1487 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1488 * charges need to be allocated between the two stacks. If all the items\n
1489 * are being dropped, it makes for a neater message to leave the original\n
1490 * stack's pval alone. -LM-\n
1492 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1494 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1496 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1497 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1499 /* Hack -- Rods also need to have their timeouts distributed. The
1500 * dropped stack will accept all time remaining to charge up to its
1503 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1505 if (q_ptr->pval > o_ptr->timeout)
1506 q_ptr->timeout = o_ptr->timeout;
1508 q_ptr->timeout = q_ptr->pval;
1510 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1516 * @brief 魔法棒やロッドの使用回数を減らす /
1517 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1518 * @param amt 減らしたい回数量 number of items that are transfered
1521 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1522 * charges of the stack needs to be reduced, unless all the items are\n
1523 * being destroyed. -LM-\n
1525 void reduce_charges(object_type *o_ptr, int amt)
1527 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1528 (amt < o_ptr->number))
1530 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1535 * Determine if an item can "absorb" a second item
1537 * See "object_absorb()" for the actual "absorption" code.
1539 * If permitted, we allow staffs (if they are known to have equal charges
1540 * and both are either known or confirmed empty) and wands (if both are
1541 * either known or confirmed empty) and rods (in all cases) to combine.
1542 * Staffs will unstack (if necessary) when they are used, but wands and
1543 * rods will only unstack if one is dropped. -LM-
1545 * If permitted, we allow weapons/armor to stack, if fully "known".
1547 * Missiles will combine if both stacks have the same "known" status.
1548 * This is done to make unidentified stacks of missiles useful.
1550 * Food, potions, scrolls, and "easy know" items always stack.
1552 * Chests, and activatable items, never stack (for various reasons).
1556 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1558 #define MAX_STACK_SIZE 99
1562 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1563 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1564 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1565 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1566 * @return 重ね合わせ可能なアイテム数
1568 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1572 /* Default maximum number of stack */
1573 int max_num = MAX_STACK_SIZE;
1575 /* Require identical object types */
1576 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1579 /* Analyze the items */
1580 switch (o_ptr->tval)
1582 /* Chests and Statues*/
1593 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1594 if (o_ptr->pval != j_ptr->pval) return 0;
1598 /* Figurines and Corpses*/
1603 if (o_ptr->pval != j_ptr->pval) return 0;
1609 /* Food and Potions and Scrolls */
1621 /* Require either knowledge or known empty for both staffs. */
1622 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1623 !object_is_known(o_ptr)) ||
1624 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1625 !object_is_known(j_ptr))) return 0;
1627 /* Require identical charges, since staffs are bulky. */
1628 if (o_ptr->pval != j_ptr->pval) return 0;
1637 /* Require either knowledge or known empty for both wands. */
1638 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1639 !object_is_known(o_ptr)) ||
1640 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1641 !object_is_known(j_ptr))) return 0;
1643 /* Wand charges combine in O&ZAngband. */
1649 /* Staffs and Wands and Rods */
1652 /* Prevent overflaw of timeout */
1653 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1659 /* Weapons and Armor */
1675 /* Rings, Amulets, Lites */
1681 /* Require full knowledge of both items */
1682 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1692 /* Require identical knowledge of both items */
1693 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1694 if (o_ptr->feeling != j_ptr->feeling) return 0;
1696 /* Require identical "bonuses" */
1697 if (o_ptr->to_h != j_ptr->to_h) return 0;
1698 if (o_ptr->to_d != j_ptr->to_d) return 0;
1699 if (o_ptr->to_a != j_ptr->to_a) return 0;
1701 /* Require identical "pval" code */
1702 if (o_ptr->pval != j_ptr->pval) return 0;
1704 /* Artifacts never stack */
1705 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1707 /* Require identical "ego-item" names */
1708 if (o_ptr->name2 != j_ptr->name2) return 0;
1710 /* Require identical added essence */
1711 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1712 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1714 /* Hack -- Never stack "powerful" items */
1715 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1717 /* Hack -- Never stack recharging items */
1718 if (o_ptr->timeout || j_ptr->timeout) return 0;
1720 /* Require identical "values" */
1721 if (o_ptr->ac != j_ptr->ac) return 0;
1722 if (o_ptr->dd != j_ptr->dd) return 0;
1723 if (o_ptr->ds != j_ptr->ds) return 0;
1732 /* Require knowledge */
1733 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1741 /* Hack -- Identical art_flags! */
1742 for (i = 0; i < TR_FLAG_SIZE; i++)
1743 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1745 /* Hack -- Require identical "cursed" status */
1746 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1748 /* Hack -- Require identical "broken" status */
1749 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1752 /* Hack -- require semi-matching "inscriptions" */
1753 if (o_ptr->inscription && j_ptr->inscription &&
1754 (o_ptr->inscription != j_ptr->inscription))
1757 /* Hack -- normally require matching "inscriptions" */
1758 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1760 /* Hack -- normally require matching "discounts" */
1761 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1764 /* They match, so they must be similar */
1769 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1770 * Determine if an item can absorb a second item.
1771 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1772 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1773 * @return 重ね合わせ可能ならばTRUEを返す。
1775 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1777 int total = o_ptr->number + j_ptr->number;
1780 /* Are these objects similar? */
1781 max_num = object_similar_part(o_ptr, j_ptr);
1783 /* Return if not similar */
1784 if (!max_num) return FALSE;
1786 /* Maximal "stacking" limit */
1787 if (total > max_num) return (0);
1790 /* They match, so they must be similar */
1796 * @brief 両オブジェクトをスロットに重ね合わせる。
1797 * Allow one item to "absorb" another, assuming they are similar
1798 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1799 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1802 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1804 int max_num = object_similar_part(o_ptr, j_ptr);
1805 int total = o_ptr->number + j_ptr->number;
1806 int diff = (total > max_num) ? total - max_num : 0;
1808 /* Combine quantity, lose excess items */
1809 o_ptr->number = (total > max_num) ? max_num : total;
1811 /* Hack -- blend "known" status */
1812 if (object_is_known(j_ptr)) object_known(o_ptr);
1814 /* Hack -- clear "storebought" if only one has it */
1815 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1816 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1818 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1819 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1822 /* Hack -- blend "mental" status */
1823 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1825 /* Hack -- blend "inscriptions" */
1826 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1828 /* Hack -- blend "feelings" */
1829 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1831 /* Hack -- could average discounts XXX XXX XXX */
1832 /* Hack -- save largest discount XXX XXX XXX */
1833 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1835 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1836 if (o_ptr->tval == TV_ROD)
1838 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1839 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1842 /* Hack -- if wands are stacking, combine the charges. -LM- */
1843 if (o_ptr->tval == TV_WAND)
1845 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1851 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1852 * Find the index of the object_kind with the given tval and sval
1853 * @param tval 検索したいベースアイテムのtval
1854 * @param sval 検索したいベースアイテムのsval
1857 s16b lookup_kind(int tval, int sval)
1864 for (k = 1; k < max_k_idx; k++)
1866 object_kind *k_ptr = &k_info[k];
1868 /* Require correct tval */
1869 if (k_ptr->tval != tval) continue;
1872 if (k_ptr->sval == sval) return (k);
1874 /* Ignore illegal items */
1875 if (sval != SV_ANY) continue;
1877 /* Apply the randomizer */
1878 if (!one_in_(++num)) continue;
1880 /* Use this value */
1884 /* Return this choice */
1892 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1902 * @brief オブジェクトを初期化する
1903 * Wipe an object clean.
1904 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1907 void object_wipe(object_type *o_ptr)
1909 /* Wipe the structure */
1910 (void)WIPE(o_ptr, object_type);
1915 * @brief オブジェクトを複製する
1916 * Wipe an object clean.
1917 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1918 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1921 void object_copy(object_type *o_ptr, object_type *j_ptr)
1923 /* Copy the structure */
1924 (void)COPY(o_ptr, j_ptr, object_type);
1929 * @brief オブジェクト構造体にベースアイテムを作成する
1930 * Prepare an object based on an object kind.
1931 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1932 * @param k_idx 新たに作成したいベースアイテム情報のID
1935 void object_prep(object_type *o_ptr, int k_idx)
1937 object_kind *k_ptr = &k_info[k_idx];
1939 /* Clear the record */
1942 /* Save the kind index */
1943 o_ptr->k_idx = k_idx;
1945 /* Efficiency -- tval/sval */
1946 o_ptr->tval = k_ptr->tval;
1947 o_ptr->sval = k_ptr->sval;
1949 /* Default "pval" */
1950 o_ptr->pval = k_ptr->pval;
1952 /* Default number */
1955 /* Default weight */
1956 o_ptr->weight = k_ptr->weight;
1959 o_ptr->to_h = k_ptr->to_h;
1960 o_ptr->to_d = k_ptr->to_d;
1961 o_ptr->to_a = k_ptr->to_a;
1964 o_ptr->ac = k_ptr->ac;
1965 o_ptr->dd = k_ptr->dd;
1966 o_ptr->ds = k_ptr->ds;
1968 /* Default activation */
1969 if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
1971 /* Hack -- worthless items are always "broken" */
1972 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1974 /* Hack -- cursed items are always "cursed" */
1975 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1976 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1977 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1978 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1979 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1980 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1985 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
1986 * Help determine an "enchantment bonus" for an object.
1987 * @param max ボーナス値の限度
1988 * @param level ボーナス値に加味する基準生成階
1989 * @return 算出されたボーナス値
1991 * To avoid floating point but still provide a smooth distribution of bonuses,\n
1992 * we simply round the results of division in such a way as to "average" the\n
1993 * correct floating point value.\n
1995 * This function has been changed. It uses "randnor()" to choose values from\n
1996 * a normal distribution, whose mean moves from zero towards the max as the\n
1997 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
1998 * and whose values are forced to lie between zero and the max, inclusive.\n
2000 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2001 * rare to get the "full" enchantment on an object, even a deep levels.\n
2003 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2005 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2007 * N 0 1 2 3 4 5 6 7 8 9 10\n
2008 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2009 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2010 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2011 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2012 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2013 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2014 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2015 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2016 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2017 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2018 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2019 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2020 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2021 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2022 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2023 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2024 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2025 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2027 s16b m_bonus(int max, int level)
2029 int bonus, stand, extra, value;
2032 /* Paranoia -- enforce maximal "level" */
2033 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2036 /* The "bonus" moves towards the max */
2037 bonus = ((max * level) / MAX_DEPTH);
2039 /* Hack -- determine fraction of error */
2040 extra = ((max * level) % MAX_DEPTH);
2042 /* Hack -- simulate floating point computations */
2043 if (randint0(MAX_DEPTH) < extra) bonus++;
2046 /* The "stand" is equal to one quarter of the max */
2049 /* Hack -- determine fraction of error */
2052 /* Hack -- simulate floating point computations */
2053 if (randint0(4) < extra) stand++;
2056 /* Choose an "interesting" value */
2057 value = randnor(bonus, stand);
2059 /* Enforce the minimum value */
2060 if (value < 0) return (0);
2062 /* Enforce the maximum value */
2063 if (value > max) return (max);
2071 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2072 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2075 static void object_mention(object_type *o_ptr)
2077 char o_name[MAX_NLEN];
2079 object_aware(o_ptr);
2080 object_known(o_ptr);
2082 /* Mark the item as fully known */
2083 o_ptr->ident |= (IDENT_MENTAL);
2086 object_desc(o_name, o_ptr, 0);
2087 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2091 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2092 * Mega-Hack -- Attempt to create one of the "Special Objects"
2093 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2094 * @return 生成に成功したらTRUEを返す。
2096 * We are only called from "make_object()", and we assume that\n
2097 * "apply_magic()" is called immediately after we return.\n
2099 * Note -- see "make_artifact()" and "apply_magic()"\n
2101 static bool make_artifact_special(object_type *o_ptr)
2106 /*! @note 地上ではキャンセルする / No artifacts in the town */
2107 if (!dun_level) return (FALSE);
2109 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2110 if (get_obj_num_hook) return (FALSE);
2112 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2113 for (i = 0; i < max_a_idx; i++)
2115 artifact_type *a_ptr = &a_info[i];
2117 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2118 if (!a_ptr->name) continue;
2120 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2121 if (a_ptr->cur_num) continue;
2122 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2123 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2125 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2126 * XXX XXX Enforce minimum "depth" (loosely) */
2127 if (a_ptr->level > object_level)
2129 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2130 int d = (a_ptr->level - object_level) * 2;
2131 if (!one_in_(d)) continue;
2134 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2135 if (!one_in_(a_ptr->rarity)) continue;
2137 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2138 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2139 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2140 if (k_info[k_idx].level > object_level)
2142 int d = (k_info[k_idx].level - object_level) * 5;
2143 if (!one_in_(d)) continue;
2146 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2147 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2148 object_prep(o_ptr, k_idx);
2151 random_artifact_resistance(o_ptr, a_ptr);
2155 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2161 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2162 * Mega-Hack -- Attempt to create one of the "Special Objects"
2163 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2164 * @return 生成に成功したらTRUEを返す。
2166 * Attempt to change an object into an artifact\n
2167 * This routine should only be called by "apply_magic()"\n
2168 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2170 static bool make_artifact(object_type *o_ptr)
2175 /* No artifacts in the town */
2176 if (!dun_level) return (FALSE);
2178 /* Paranoia -- no "plural" artifacts */
2179 if (o_ptr->number != 1) return (FALSE);
2181 /* Check the artifact list (skip the "specials") */
2182 for (i = 0; i < max_a_idx; i++)
2184 artifact_type *a_ptr = &a_info[i];
2186 /* Skip "empty" items */
2187 if (!a_ptr->name) continue;
2189 /* Cannot make an artifact twice */
2190 if (a_ptr->cur_num) continue;
2192 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2194 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2196 /* Must have the correct fields */
2197 if (a_ptr->tval != o_ptr->tval) continue;
2198 if (a_ptr->sval != o_ptr->sval) continue;
2200 /* XXX XXX Enforce minimum "depth" (loosely) */
2201 if (a_ptr->level > dun_level)
2203 /* Acquire the "out-of-depth factor" */
2204 int d = (a_ptr->level - dun_level) * 2;
2206 /* Roll for out-of-depth creation */
2207 if (!one_in_(d)) continue;
2210 /* We must make the "rarity roll" */
2211 if (!one_in_(a_ptr->rarity)) continue;
2213 /* Hack -- mark the item as an artifact */
2216 /* Hack: Some artifacts get random extra powers */
2217 random_artifact_resistance(o_ptr, a_ptr);
2229 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2230 * Choose random ego type
2231 * @param slot 取得したいエゴの装備部位
2232 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2233 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2235 static byte get_random_ego(byte slot, bool good)
2238 ego_item_type *e_ptr;
2242 for (i = 1; i < max_e_idx; i++)
2246 if (e_ptr->slot == slot
2247 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2250 total += (255 / e_ptr->rarity);
2254 value = randint1(total);
2256 for (i = 1; i < max_e_idx; i++)
2260 if (e_ptr->slot == slot
2261 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2264 value -= (255 / e_ptr->rarity);
2265 if (value <= 0L) break;
2273 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2274 * Apply magic to an item known to be a "weapon"
2275 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2276 * @param level 生成基準階
2277 * @param power 生成ランク
2280 * Hack -- note special base damage dice boosting\n
2281 * Hack -- note special processing for weapon/digger\n
2283 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2285 HIT_PROB tohit1 = randint1(5) + m_bonus(5, level);
2286 HIT_POINT todam1 = randint1(5) + m_bonus(5, level);
2288 HIT_PROB tohit2 = m_bonus(10, level);
2289 HIT_POINT todam2 = m_bonus(10, level);
2291 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2293 tohit2 = (tohit2+1)/2;
2294 todam2 = (todam2+1)/2;
2301 o_ptr->to_h += tohit1;
2302 o_ptr->to_d += todam1;
2308 o_ptr->to_h += tohit2;
2309 o_ptr->to_d += todam2;
2317 o_ptr->to_h -= tohit1;
2318 o_ptr->to_d -= todam1;
2323 /* Penalize again */
2324 o_ptr->to_h -= tohit2;
2325 o_ptr->to_d -= todam2;
2328 /* Cursed (if "bad") */
2329 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2332 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2335 switch (o_ptr->tval)
2342 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2343 create_artifact(o_ptr, FALSE);
2345 /* Special Ego-item */
2346 o_ptr->name2 = EGO_DIGGING;
2350 else if (power < -1)
2352 /* Hack -- Horrible digging bonus */
2353 o_ptr->pval = 0 - (5 + randint1(5));
2359 /* Hack -- Reverse digging bonus */
2360 o_ptr->pval = 0 - (o_ptr->pval);
2374 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2376 create_artifact(o_ptr, FALSE);
2381 /* Roll for an ego-item */
2382 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2383 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2385 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2387 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2392 switch (o_ptr->name2)
2395 if (one_in_(4) && (level > 40))
2396 add_flag(o_ptr->art_flags, TR_BLOWS);
2400 add_flag(o_ptr->art_flags, TR_RES_POIS);
2402 add_flag(o_ptr->art_flags, TR_WARNING);
2404 case EGO_KILL_DRAGON:
2406 add_flag(o_ptr->art_flags, TR_RES_POIS);
2410 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2412 case EGO_SLAYING_WEAPON:
2413 if (one_in_(3)) /* double damage */
2421 while (one_in_(o_ptr->dd));
2427 while (one_in_(o_ptr->ds));
2432 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2434 if (o_ptr->tval == TV_SWORD && one_in_(3))
2436 add_flag(o_ptr->art_flags, TR_VORPAL);
2441 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2447 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2449 add_flag(o_ptr->art_flags, TR_DEX);
2451 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2454 o_ptr->pval = m_bonus(5, level) + 1;
2456 case EGO_EARTHQUAKES:
2457 if (one_in_(3) && (level > 60))
2458 add_flag(o_ptr->art_flags, TR_BLOWS);
2460 o_ptr->pval = m_bonus(3, level);
2464 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2468 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2470 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2472 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2473 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2476 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2477 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2478 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2479 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2483 if (!o_ptr->art_name)
2485 /* Hack -- Super-charge the damage dice */
2486 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2488 /* Hack -- Lower the damage dice */
2489 if (o_ptr->dd > 9) o_ptr->dd = 9;
2494 else if (power < -1)
2496 /* Roll for ego-item */
2497 if (randint0(MAX_DEPTH) < level)
2501 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2502 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2508 switch (o_ptr->name2)
2511 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2512 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2514 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2515 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2516 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2517 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2518 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2519 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2533 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2535 create_artifact(o_ptr, FALSE);
2538 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2552 if (power > 2) /* power > 2 is debug only */
2554 create_artifact(o_ptr, FALSE);
2558 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2560 switch (o_ptr->name2)
2562 case EGO_SLAYING_BOLT:
2567 /* Hack -- super-charge the damage dice */
2568 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2570 /* Hack -- restrict the damage dice */
2571 if (o_ptr->dd > 9) o_ptr->dd = 9;
2575 else if (power < -1)
2577 /* Roll for ego-item */
2578 if (randint0(MAX_DEPTH) < level)
2580 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2590 * @brief ドラゴン装備にランダムな耐性を与える
2591 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2594 static void dragon_resist(object_type * o_ptr)
2599 one_dragon_ele_resistance(o_ptr);
2601 one_high_resistance(o_ptr);
2607 * @brief オブジェクトにランダムな強いESPを与える
2608 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2611 static bool add_esp_strong(object_type *o_ptr)
2613 bool nonliv = FALSE;
2615 switch (randint1(3))
2617 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2618 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2619 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2626 * @brief オブジェクトにランダムな弱いESPを与える
2627 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2628 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2631 static void add_esp_weak(object_type *o_ptr, bool extra)
2634 u32b weak_esp_list[] = {
2646 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2647 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2649 /* Add unduplicated weak esp flags randomly */
2650 for (i = 0; i < add_count; ++ i)
2652 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2654 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2655 weak_esp_list[choice] = weak_esp_list[i];
2661 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2662 * Apply magic to an item known to be "armor"
2663 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2664 * @param level 生成基準階
2665 * @param power 生成ランク
2668 * Hack -- note special processing for crown/helm\n
2669 * Hack -- note special processing for robe of permanence\n
2671 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2673 ARMOUR_CLASS toac1 = randint1(5) + m_bonus(5, level);
2674 ARMOUR_CLASS toac2 = m_bonus(10, level);
2680 o_ptr->to_a += toac1;
2686 o_ptr->to_a += toac2;
2694 o_ptr->to_a -= toac1;
2699 /* Penalize again */
2700 o_ptr->to_a -= toac2;
2703 /* Cursed (if "bad") */
2704 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2709 switch (o_ptr->tval)
2713 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2714 create_artifact(o_ptr, FALSE);
2724 /* Hack -- Try for "Robes of the Magi" */
2725 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2726 (o_ptr->sval == SV_ROBE) &&
2727 (randint0(100) < 15))
2731 o_ptr->name2 = EGO_YOIYAMI;
2732 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2733 o_ptr->sval = SV_YOIYAMI_ROBE;
2739 o_ptr->name2 = EGO_PERMANENCE;
2744 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2746 create_artifact(o_ptr, FALSE);
2752 bool okay_flag = TRUE;
2754 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2756 switch (o_ptr->name2)
2759 if (o_ptr->tval != TV_HARD_ARMOR)
2765 if (o_ptr->tval != TV_SOFT_ARMOR)
2774 if (okay_flag) break;
2776 switch (o_ptr->name2)
2778 case EGO_RESISTANCE:
2780 add_flag(o_ptr->art_flags, TR_RES_POIS);
2783 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2784 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2788 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2790 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2792 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2793 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2795 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2796 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2797 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2798 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2799 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2800 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2801 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2802 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2805 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2806 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2807 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2808 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2809 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2810 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2823 if (o_ptr->sval == SV_DRAGON_SHIELD)
2825 dragon_resist(o_ptr);
2826 if (!one_in_(3)) break;
2832 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2834 create_artifact(o_ptr, FALSE);
2840 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2841 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2842 && o_ptr->name2 == EGO_S_DWARVEN)
2849 switch (o_ptr->name2)
2852 if (!one_in_(3)) one_high_resistance(o_ptr);
2853 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2855 case EGO_REFLECTION:
2856 if (o_ptr->sval == SV_MIRROR_SHIELD)
2861 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2862 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2871 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2873 dragon_resist(o_ptr);
2874 if (!one_in_(3)) break;
2878 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2880 create_artifact(o_ptr, FALSE);
2883 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2887 else if (power < -1)
2889 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2897 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2899 dragon_resist(o_ptr);
2900 if (!one_in_(3)) break;
2905 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2907 create_artifact(o_ptr, FALSE);
2910 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2912 switch (o_ptr->name2)
2914 case EGO_SLOW_DESCENT:
2917 one_high_resistance(o_ptr);
2923 else if (power < -1)
2925 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2936 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2938 create_artifact(o_ptr, FALSE);
2943 bool ok_flag = TRUE;
2944 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2946 switch (o_ptr->name2)
2949 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2950 else add_esp_weak(o_ptr, FALSE);
2954 case EGO_REGENERATION:
2955 case EGO_LORDLINESS:
2961 if (one_in_(2)) add_esp_strong(o_ptr);
2962 else add_esp_weak(o_ptr, FALSE);
2965 default:/* not existing crown (wisdom,lite, etc...) */
2969 break; /* while (1) */
2975 else if (power < -1)
2979 bool ok_flag = TRUE;
2980 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
2982 switch (o_ptr->name2)
2984 case EGO_ANCIENT_CURSE:
2985 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2986 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2987 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2988 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2989 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2990 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2994 break; /* while (1) */
3003 if (o_ptr->sval == SV_DRAGON_HELM)
3005 dragon_resist(o_ptr);
3006 if (!one_in_(3)) break;
3012 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3014 create_artifact(o_ptr, FALSE);
3019 bool ok_flag = TRUE;
3020 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3022 switch (o_ptr->name2)
3024 case EGO_BRILLIANCE:
3026 case EGO_INFRAVISION:
3027 case EGO_H_PROTECTION:
3032 if (one_in_(2)) add_esp_strong(o_ptr);
3033 else add_esp_weak(o_ptr, FALSE);
3037 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3038 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3041 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3043 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3045 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3046 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3048 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3049 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3050 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3051 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3052 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3053 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3054 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3055 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3057 default:/* not existing helm (Magi, Might, etc...)*/
3061 break; /* while (1) */
3066 else if (power < -1)
3070 bool ok_flag = TRUE;
3071 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3073 switch (o_ptr->name2)
3075 case EGO_ANCIENT_CURSE:
3079 break; /* while (1) */
3090 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3092 create_artifact(o_ptr, FALSE);
3095 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3097 switch (o_ptr->name2)
3106 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3107 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3108 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3109 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3116 else if (power < -1)
3118 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3129 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3130 * Apply magic to an item known to be a "ring" or "amulet"
3131 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3132 * @param level 生成基準階
3133 * @param power 生成ランク
3136 * Hack -- note special "pval boost" code for ring of speed\n
3137 * Hack -- note that some items must be cursed (or blessed)\n
3139 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3141 /* Apply magic (good or bad) according to type */
3142 switch (o_ptr->tval)
3147 switch (o_ptr->sval)
3149 case SV_RING_ATTACKS:
3152 o_ptr->pval = m_bonus(2, level);
3153 if (one_in_(15)) o_ptr->pval++;
3154 if (o_ptr->pval < 1) o_ptr->pval = 1;
3160 o_ptr->ident |= (IDENT_BROKEN);
3163 o_ptr->curse_flags |= TRC_CURSED;
3166 o_ptr->pval = 0 - (o_ptr->pval);
3177 /* Strength, Constitution, Dexterity, Intelligence */
3183 o_ptr->pval = 1 + m_bonus(5, level);
3189 o_ptr->ident |= (IDENT_BROKEN);
3192 o_ptr->curse_flags |= TRC_CURSED;
3195 o_ptr->pval = 0 - (o_ptr->pval);
3201 /* Ring of Speed! */
3204 /* Base speed (1 to 10) */
3205 o_ptr->pval = randint1(5) + m_bonus(5, level);
3207 /* Super-charge the ring */
3208 while (randint0(100) < 50) o_ptr->pval++;
3214 o_ptr->ident |= (IDENT_BROKEN);
3217 o_ptr->curse_flags |= TRC_CURSED;
3220 o_ptr->pval = 0 - (o_ptr->pval);
3228 case SV_RING_LORDLY:
3232 one_lordly_high_resistance(o_ptr);
3236 /* Bonus to armor class */
3237 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3241 case SV_RING_WARNING:
3243 if (one_in_(3)) one_low_esp(o_ptr);
3248 case SV_RING_SEARCHING:
3250 /* Bonus to searching */
3251 o_ptr->pval = 1 + m_bonus(5, level);
3257 o_ptr->ident |= (IDENT_BROKEN);
3260 o_ptr->curse_flags |= TRC_CURSED;
3263 o_ptr->pval = 0 - (o_ptr->pval);
3269 /* Flames, Acid, Ice */
3270 case SV_RING_FLAMES:
3275 /* Bonus to armor class */
3276 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3280 /* Weakness, Stupidity */
3281 case SV_RING_WEAKNESS:
3282 case SV_RING_STUPIDITY:
3285 o_ptr->ident |= (IDENT_BROKEN);
3288 o_ptr->curse_flags |= TRC_CURSED;
3291 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3292 if (power > 0) power = 0 - power;
3297 /* WOE, Stupidity */
3301 o_ptr->ident |= (IDENT_BROKEN);
3304 o_ptr->curse_flags |= TRC_CURSED;
3307 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3308 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3309 if (power > 0) power = 0 - power;
3314 /* Ring of damage */
3315 case SV_RING_DAMAGE:
3317 /* Bonus to damage */
3318 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3324 o_ptr->ident |= (IDENT_BROKEN);
3327 o_ptr->curse_flags |= TRC_CURSED;
3330 o_ptr->to_d = 0 - o_ptr->to_d;
3336 /* Ring of Accuracy */
3337 case SV_RING_ACCURACY:
3340 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3346 o_ptr->ident |= (IDENT_BROKEN);
3349 o_ptr->curse_flags |= TRC_CURSED;
3352 o_ptr->to_h = 0 - o_ptr->to_h;
3358 /* Ring of Protection */
3359 case SV_RING_PROTECTION:
3361 /* Bonus to armor class */
3362 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3368 o_ptr->ident |= (IDENT_BROKEN);
3371 o_ptr->curse_flags |= TRC_CURSED;
3374 o_ptr->to_a = 0 - o_ptr->to_a;
3380 /* Ring of Slaying */
3381 case SV_RING_SLAYING:
3383 /* Bonus to damage and to hit */
3384 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3385 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3391 o_ptr->ident |= (IDENT_BROKEN);
3394 o_ptr->curse_flags |= TRC_CURSED;
3396 /* Reverse bonuses */
3397 o_ptr->to_h = 0 - o_ptr->to_h;
3398 o_ptr->to_d = 0 - o_ptr->to_d;
3404 case SV_RING_MUSCLE:
3406 o_ptr->pval = 1 + m_bonus(3, level);
3407 if (one_in_(4)) o_ptr->pval++;
3413 o_ptr->ident |= (IDENT_BROKEN);
3416 o_ptr->curse_flags |= TRC_CURSED;
3418 /* Reverse bonuses */
3419 o_ptr->pval = 0 - o_ptr->pval;
3424 case SV_RING_AGGRAVATION:
3427 o_ptr->ident |= (IDENT_BROKEN);
3430 o_ptr->curse_flags |= TRC_CURSED;
3432 if (power > 0) power = 0 - power;
3436 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3437 || (power > 2)) /* power > 2 is debug only */
3439 o_ptr->pval = MIN(o_ptr->pval, 4);
3440 /* Randart amulet */
3441 create_artifact(o_ptr, FALSE);
3443 else if ((power == 2) && one_in_(2))
3445 while(!o_ptr->name2)
3447 int tmp = m_bonus(10, level);
3448 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3449 switch(randint1(28))
3452 o_ptr->name2 = EGO_RING_THROW;
3455 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3456 o_ptr->name2 = EGO_RING_REGEN;
3459 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3460 o_ptr->name2 = EGO_RING_LITE;
3463 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3464 o_ptr->name2 = EGO_RING_TELEPORT;
3467 if (o_ptr->to_h) break;
3468 o_ptr->name2 = EGO_RING_TO_H;
3471 if (o_ptr->to_d) break;
3472 o_ptr->name2 = EGO_RING_TO_D;
3475 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3476 o_ptr->name2 = EGO_RING_SLAY;
3479 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3480 o_ptr->name2 = EGO_RING_WIZARD;
3483 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3484 o_ptr->name2 = EGO_RING_HERO;
3487 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3488 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3489 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3490 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3493 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3494 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;
3495 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3496 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3497 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3500 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3501 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;
3502 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3503 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3504 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3507 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3508 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;
3509 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3510 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3513 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3514 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;
3515 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3516 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3518 case 21: case 22: case 23: case 24: case 25: case 26:
3519 switch (o_ptr->sval)
3522 if (!one_in_(3)) break;
3523 o_ptr->name2 = EGO_RING_D_SPEED;
3525 case SV_RING_DAMAGE:
3526 case SV_RING_ACCURACY:
3527 case SV_RING_SLAYING:
3528 if (one_in_(2)) break;
3529 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3532 o_ptr->name2 = EGO_RING_BERSERKER;
3533 o_ptr->to_h -= 2+randint1(4);
3534 o_ptr->to_d += 2+randint1(4);
3537 case SV_RING_PROTECTION:
3538 o_ptr->name2 = EGO_RING_SUPER_AC;
3539 o_ptr->to_a += 7 + m_bonus(5, level);
3541 case SV_RING_RES_FEAR:
3542 o_ptr->name2 = EGO_RING_HERO;
3545 if (one_in_(2)) break;
3546 o_ptr->name2 = EGO_RING_HUNTER;
3548 case SV_RING_SEARCHING:
3549 o_ptr->name2 = EGO_RING_STEALTH;
3551 case SV_RING_TELEPORTATION:
3552 o_ptr->name2 = EGO_RING_TELE_AWAY;
3554 case SV_RING_RES_BLINDNESS:
3556 o_ptr->name2 = EGO_RING_RES_LITE;
3558 o_ptr->name2 = EGO_RING_RES_DARK;
3560 case SV_RING_LORDLY:
3561 if (!one_in_(20)) break;
3562 one_lordly_high_resistance(o_ptr);
3563 one_lordly_high_resistance(o_ptr);
3564 o_ptr->name2 = EGO_RING_TRUE;
3566 case SV_RING_SUSTAIN:
3567 if (!one_in_(4)) break;
3568 o_ptr->name2 = EGO_RING_RES_TIME;
3570 case SV_RING_FLAMES:
3571 if (!one_in_(2)) break;
3572 o_ptr->name2 = EGO_RING_DRAGON_F;
3575 if (!one_in_(2)) break;
3576 o_ptr->name2 = EGO_RING_DRAGON_C;
3578 case SV_RING_WARNING:
3579 if (!one_in_(2)) break;
3580 o_ptr->name2 = EGO_RING_M_DETECT;
3589 o_ptr->curse_flags = 0L;
3591 else if ((power == -2) && one_in_(2))
3593 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3594 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3595 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3596 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3597 o_ptr->art_flags[0] = 0;
3598 o_ptr->art_flags[1] = 0;
3599 while(!o_ptr->name2)
3601 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3605 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3606 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3609 o_ptr->name2 = EGO_RING_NO_MELEE;
3612 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3613 o_ptr->name2 = EGO_RING_AGGRAVATE;
3616 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3617 o_ptr->name2 = EGO_RING_TY_CURSE;
3620 o_ptr->name2 = EGO_RING_ALBINO;
3625 o_ptr->ident |= (IDENT_BROKEN);
3628 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3636 switch (o_ptr->sval)
3638 /* Amulet of wisdom/charisma */
3639 case SV_AMULET_INTELLIGENCE:
3640 case SV_AMULET_WISDOM:
3641 case SV_AMULET_CHARISMA:
3643 o_ptr->pval = 1 + m_bonus(5, level);
3649 o_ptr->ident |= (IDENT_BROKEN);
3652 o_ptr->curse_flags |= (TRC_CURSED);
3654 /* Reverse bonuses */
3655 o_ptr->pval = 0 - o_ptr->pval;
3661 /* Amulet of brilliance */
3662 case SV_AMULET_BRILLIANCE:
3664 o_ptr->pval = 1 + m_bonus(3, level);
3665 if (one_in_(4)) o_ptr->pval++;
3671 o_ptr->ident |= (IDENT_BROKEN);
3674 o_ptr->curse_flags |= (TRC_CURSED);
3676 /* Reverse bonuses */
3677 o_ptr->pval = 0 - o_ptr->pval;
3683 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3687 o_ptr->curse_flags |= (TRC_CURSED);
3692 case SV_AMULET_RESISTANCE:
3694 if (one_in_(5)) one_high_resistance(o_ptr);
3695 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3699 /* Amulet of searching */
3700 case SV_AMULET_SEARCHING:
3702 o_ptr->pval = randint1(2) + m_bonus(4, level);
3708 o_ptr->ident |= (IDENT_BROKEN);
3711 o_ptr->curse_flags |= (TRC_CURSED);
3713 /* Reverse bonuses */
3714 o_ptr->pval = 0 - (o_ptr->pval);
3720 /* Amulet of the Magi -- never cursed */
3721 case SV_AMULET_THE_MAGI:
3723 o_ptr->pval = randint1(5) + m_bonus(5, level);
3724 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3726 /* gain one low ESP */
3727 add_esp_weak(o_ptr, FALSE);
3732 /* Amulet of Doom -- always cursed */
3733 case SV_AMULET_DOOM:
3736 o_ptr->ident |= (IDENT_BROKEN);
3739 o_ptr->curse_flags |= (TRC_CURSED);
3742 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3743 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3744 if (power > 0) power = 0 - power;
3749 case SV_AMULET_MAGIC_MASTERY:
3751 o_ptr->pval = 1 + m_bonus(4, level);
3757 o_ptr->ident |= (IDENT_BROKEN);
3760 o_ptr->curse_flags |= (TRC_CURSED);
3762 /* Reverse bonuses */
3763 o_ptr->pval = 0 - o_ptr->pval;
3769 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3770 || (power > 2)) /* power > 2 is debug only */
3772 o_ptr->pval = MIN(o_ptr->pval, 4);
3773 /* Randart amulet */
3774 create_artifact(o_ptr, FALSE);
3776 else if ((power == 2) && one_in_(2))
3778 while(!o_ptr->name2)
3780 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3781 switch(randint1(21))
3784 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3785 o_ptr->name2 = EGO_AMU_SLOW_D;
3788 if (o_ptr->pval) break;
3789 o_ptr->name2 = EGO_AMU_INFRA;
3792 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3793 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3796 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3797 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3800 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3801 o_ptr->name2 = EGO_AMU_LEVITATION;
3803 case 10: case 11: case 21:
3804 o_ptr->name2 = EGO_AMU_AC;
3807 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3808 if (m_bonus(10, level) > 8)
3809 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3811 o_ptr->name2 = EGO_AMU_RES_FIRE;
3814 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3815 if (m_bonus(10, level) > 8)
3816 o_ptr->name2 = EGO_AMU_RES_COLD_;
3818 o_ptr->name2 = EGO_AMU_RES_COLD;
3821 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3822 if (m_bonus(10, level) > 8)
3823 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3825 o_ptr->name2 = EGO_AMU_RES_ELEC;
3828 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3829 if (m_bonus(10, level) > 8)
3830 o_ptr->name2 = EGO_AMU_RES_ACID_;
3832 o_ptr->name2 = EGO_AMU_RES_ACID;
3834 case 16: case 17: case 18: case 19: case 20:
3835 switch (o_ptr->sval)
3837 case SV_AMULET_TELEPORT:
3838 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3839 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3840 else o_ptr->name2 = EGO_AMU_TELEPORT;
3842 case SV_AMULET_RESIST_ACID:
3843 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3845 case SV_AMULET_SEARCHING:
3846 o_ptr->name2 = EGO_AMU_STEALTH;
3848 case SV_AMULET_BRILLIANCE:
3849 if (!one_in_(3)) break;
3850 o_ptr->name2 = EGO_AMU_IDENT;
3852 case SV_AMULET_CHARISMA:
3853 if (!one_in_(3)) break;
3854 o_ptr->name2 = EGO_AMU_CHARM;
3856 case SV_AMULET_THE_MAGI:
3857 if (one_in_(2)) break;
3858 o_ptr->name2 = EGO_AMU_GREAT;
3860 case SV_AMULET_RESISTANCE:
3861 if (!one_in_(5)) break;
3862 o_ptr->name2 = EGO_AMU_DEFENDER;
3864 case SV_AMULET_TELEPATHY:
3865 if (!one_in_(3)) break;
3866 o_ptr->name2 = EGO_AMU_DETECTION;
3872 o_ptr->curse_flags = 0L;
3874 else if ((power == -2) && one_in_(2))
3876 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3877 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3878 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3879 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3880 o_ptr->art_flags[0] = 0;
3881 o_ptr->art_flags[1] = 0;
3882 while(!o_ptr->name2)
3884 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3888 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3889 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3892 o_ptr->name2 = EGO_AMU_FOOL;
3895 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3896 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3899 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3900 o_ptr->name2 = EGO_AMU_TY_CURSE;
3903 o_ptr->name2 = EGO_AMU_NAIVETY;
3908 o_ptr->ident |= (IDENT_BROKEN);
3911 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3919 * @brief モンスターが人形のベースにできるかを返す
3920 * @param r_idx チェックしたいモンスター種族のID
3921 * @return 人形にできるならTRUEを返す
3923 static bool item_monster_okay(int r_idx)
3925 monster_race *r_ptr = &r_info[r_idx];
3928 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3929 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3930 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3931 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3932 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3933 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3941 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3942 * Apply magic to an item known to be "boring"
3943 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3944 * @param level 生成基準階
3945 * @param power 生成ランク
3948 * Hack -- note the special code for various items
3950 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3952 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3957 /* Apply magic (good or bad) according to type */
3958 switch (o_ptr->tval)
3967 o_ptr->ident |= (IDENT_BROKEN);
3970 o_ptr->curse_flags |= (TRC_CURSED);
3977 o_ptr->xtra4 = o_ptr->pval;
3983 /* Hack -- Torches -- random fuel */
3984 if (o_ptr->sval == SV_LITE_TORCH)
3986 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3990 /* Hack -- Lanterns -- random fuel */
3991 if (o_ptr->sval == SV_LITE_LANTERN)
3993 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3997 if (power > 2) /* power > 2 is debug only */
3999 create_artifact(o_ptr, FALSE);
4001 else if ((power == 2) || ((power == 1) && one_in_(3)))
4003 while (!o_ptr->name2)
4007 bool okay_flag = TRUE;
4009 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4011 switch (o_ptr->name2)
4014 if (o_ptr->sval == SV_LITE_FEANOR)
4022 else if (power == -2)
4024 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4026 switch (o_ptr->name2)
4028 case EGO_LITE_DARKNESS:
4031 if (o_ptr->sval == SV_LITE_TORCH)
4033 add_flag(o_ptr->art_flags, TR_LITE_M1);
4035 else if (o_ptr->sval == SV_LITE_LANTERN)
4037 add_flag(o_ptr->art_flags, TR_LITE_M2);
4039 else if (o_ptr->sval == SV_LITE_FEANOR)
4041 add_flag(o_ptr->art_flags, TR_LITE_M3);
4053 /* The wand or staff gets a number of initial charges equal
4054 * to between 1/2 (+1) and the full object kind's pval. -LM-
4056 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4062 /* Transfer the pval. -LM- */
4063 o_ptr->pval = k_ptr->pval;
4070 object_aware(o_ptr);
4071 object_known(o_ptr);
4080 monster_race *r_ptr;
4082 /* Pick a random non-unique monster race */
4085 i = randint1(max_r_idx - 1);
4087 if (!item_monster_okay(i)) continue;
4088 if (i == MON_TSUCHINOKO) continue;
4092 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4094 /* Ignore dead monsters */
4095 if (!r_ptr->rarity) continue;
4097 /* Ignore uncommon monsters */
4098 if (r_ptr->rarity > 100) continue;
4100 /* Prefer less out-of-depth monsters */
4101 if (randint0(check)) continue;
4108 /* Some figurines are cursed */
4109 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4121 monster_race *r_ptr;
4123 if (o_ptr->sval == SV_SKELETON)
4125 match = RF9_DROP_SKELETON;
4127 else if (o_ptr->sval == SV_CORPSE)
4129 match = RF9_DROP_CORPSE;
4132 /* Hack -- Remove the monster restriction */
4133 get_mon_num_prep(item_monster_okay, NULL);
4135 /* Pick a random non-unique monster race */
4138 i = get_mon_num(dun_level);
4142 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4144 /* Ignore dead monsters */
4145 if (!r_ptr->rarity) continue;
4147 /* Ignore corpseless monsters */
4148 if (!(r_ptr->flags9 & match)) continue;
4150 /* Prefer less out-of-depth monsters */
4151 if (randint0(check)) continue;
4159 object_aware(o_ptr);
4160 object_known(o_ptr);
4168 monster_race *r_ptr;
4170 /* Pick a random monster race */
4173 i = randint1(max_r_idx - 1);
4177 /* Ignore dead monsters */
4178 if (!r_ptr->rarity) continue;
4187 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4189 object_aware(o_ptr);
4190 object_known(o_ptr);
4197 byte obj_level = k_info[o_ptr->k_idx].level;
4199 /* Hack -- skip ruined chests */
4200 if (obj_level <= 0) break;
4202 /* Hack -- pick a "difficulty" */
4203 o_ptr->pval = randint1(obj_level);
4204 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4206 o_ptr->xtra3 = dun_level + 5;
4208 /* Never exceed "difficulty" of 55 to 59 */
4209 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4217 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4218 * Complete the "creation" of an object by applying "magic" to the item
4219 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4221 * @param mode 生成オプション
4224 * This includes not only rolling for random bonuses, but also putting the\n
4225 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4226 * staffs, giving fuel to lites, and placing traps on chests.\n
4228 * In particular, note that "Instant Artifacts", if "created" by an external\n
4229 * routine, must pass through this function to complete the actual creation.\n
4231 * The base "chance" of the item being "good" increases with the "level"\n
4232 * parameter, which is usually derived from the dungeon level, being equal\n
4233 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4234 * the object is guaranteed to be "good". If an object is "good", then\n
4235 * the chance that the object will be "great" (ego-item or artifact), also\n
4236 * increases with the "level", being equal to half the level, plus 5, up to\n
4237 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4238 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4240 * If the object is not "good", there is a chance it will be "cursed", and\n
4241 * if it is "cursed", there is a chance it will be "broken". These chances\n
4242 * are related to the "good" / "great" chances above.\n
4244 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4245 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4247 * If "okay" is true, and the object is going to be "great", then there is\n
4248 * a chance that an artifact will be created. This is true even if both the\n
4249 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4250 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4252 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4254 int i, rolls, f1, f2, power;
4256 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4258 /* Maximum "level" for various things */
4259 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4261 /* Base chance of being "good" */
4264 /* Maximal chance of being "good" */
4265 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4267 /* Base chance of being "great" */
4270 /* Maximal chance of being "great" */
4271 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4272 f2 = d_info[dungeon_type].obj_great;
4274 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4279 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4288 /* Roll for "good" */
4289 if ((mode & AM_GOOD) || magik(f1))
4294 /* Roll for "great" */
4295 if ((mode & AM_GREAT) || magik(f2))
4299 /* Roll for "special" */
4300 if (mode & AM_SPECIAL) power = 3;
4304 /* Roll for "cursed" */
4307 /* Assume "cursed" */
4310 /* Roll for "broken" */
4311 if (magik(f2)) power = -2;
4315 if (mode & AM_CURSED)
4317 /* Assume 'cursed' */
4322 /* Everything else gets more badly cursed */
4329 /* Assume no rolls */
4332 /* Get one roll if excellent */
4333 if (power >= 2) rolls = 1;
4335 /* Hack -- Get four rolls if forced great or special */
4336 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4338 /* Hack -- Get no rolls if not allowed */
4339 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4341 /* Roll for artifacts if allowed */
4342 for (i = 0; i < rolls; i++)
4344 /* Roll for an artifact */
4345 if (make_artifact(o_ptr)) break;
4346 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4348 if (make_artifact(o_ptr)) break;
4353 /* Hack -- analyze artifacts */
4354 if (object_is_fixed_artifact(o_ptr))
4356 artifact_type *a_ptr = &a_info[o_ptr->name1];
4358 /* Hack -- Mark the artifact as "created" */
4361 /* Hack -- Memorize location of artifact in saved floors */
4362 if (character_dungeon)
4363 a_ptr->floor_id = p_ptr->floor_id;
4365 /* Extract the other fields */
4366 o_ptr->pval = a_ptr->pval;
4367 o_ptr->ac = a_ptr->ac;
4368 o_ptr->dd = a_ptr->dd;
4369 o_ptr->ds = a_ptr->ds;
4370 o_ptr->to_a = a_ptr->to_a;
4371 o_ptr->to_h = a_ptr->to_h;
4372 o_ptr->to_d = a_ptr->to_d;
4373 o_ptr->weight = a_ptr->weight;
4374 o_ptr->xtra2 = a_ptr->act_idx;
4376 if (o_ptr->name1 == ART_MILIM)
4378 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4384 /* Hack -- extract the "broken" flag */
4385 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4387 /* Hack -- extract the "cursed" flag */
4388 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4389 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4390 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4391 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4392 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4393 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4401 switch (o_ptr->tval)
4410 if (power) a_m_aux_1(o_ptr, lev, power);
4416 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4422 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4436 /* Elven Cloak and Black Clothes ... */
4437 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4438 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4439 o_ptr->pval = randint1(4);
4443 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4444 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4445 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4446 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4447 a_m_aux_2(o_ptr, lev, power);
4449 if (power) a_m_aux_2(o_ptr, lev, power);
4457 if (!power && (randint0(100) < 50)) power = -1;
4458 a_m_aux_3(o_ptr, lev, power);
4464 a_m_aux_4(o_ptr, lev, power);
4469 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4470 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4471 (p_ptr->pseikaku == SEIKAKU_SEXY))
4474 add_flag(o_ptr->art_flags, TR_STR);
4475 add_flag(o_ptr->art_flags, TR_INT);
4476 add_flag(o_ptr->art_flags, TR_WIS);
4477 add_flag(o_ptr->art_flags, TR_DEX);
4478 add_flag(o_ptr->art_flags, TR_CON);
4479 add_flag(o_ptr->art_flags, TR_CHR);
4482 /* Hack -- analyze ego-items */
4483 if (object_is_ego(o_ptr))
4485 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4487 /* Hack -- acquire "broken" flag */
4488 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4490 /* Hack -- acquire "cursed" flag */
4491 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4492 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4493 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4494 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4495 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4496 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4498 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4499 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4500 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4501 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4502 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4503 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4504 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4505 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4511 while (one_in_(o_ptr->dd));
4513 if (o_ptr->dd > 9) o_ptr->dd = 9;
4516 /* Hack -- apply activatin index if needed */
4517 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4519 /* Hack -- apply extra penalties if needed */
4520 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4522 /* Hack -- obtain bonuses */
4523 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4524 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4525 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4527 /* Hack -- obtain pval */
4528 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4531 /* Hack -- apply extra bonuses if needed */
4534 /* Hack -- obtain bonuses */
4535 if (e_ptr->max_to_h)
4537 if (e_ptr->max_to_h > 127)
4538 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4539 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4541 if (e_ptr->max_to_d)
4543 if (e_ptr->max_to_d > 127)
4544 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4545 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4547 if (e_ptr->max_to_a)
4549 if (e_ptr->max_to_a > 127)
4550 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4551 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4554 /* Accuracy ego must have high to_h */
4555 if(o_ptr->name2 == EGO_ACCURACY)
4557 while(o_ptr->to_h < o_ptr->to_d + 10)
4562 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4565 /* Accuracy ego must have high to_h */
4566 if(o_ptr->name2 == EGO_VELOCITY)
4568 while(o_ptr->to_d < o_ptr->to_h + 10)
4573 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4576 /* Protection ego must have high to_a */
4577 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4579 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4582 /* Hack -- obtain pval */
4583 if (e_ptr->max_pval)
4585 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4588 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4590 else if (o_ptr->name2 == EGO_DEMON)
4592 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4594 o_ptr->pval += randint1(2);
4598 o_ptr->pval += randint1(e_ptr->max_pval);
4601 else if (o_ptr->name2 == EGO_ATTACKS)
4603 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4604 if (o_ptr->pval > 3) o_ptr->pval = 3;
4605 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4606 o_ptr->pval += randint1(2);
4608 else if (o_ptr->name2 == EGO_BAT)
4610 o_ptr->pval = randint1(e_ptr->max_pval);
4611 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4613 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4615 o_ptr->pval = randint1(e_ptr->max_pval);
4619 o_ptr->pval += randint1(e_ptr->max_pval);
4624 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4626 o_ptr->pval = randint1(o_ptr->pval);
4628 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4636 /* Examine real objects */
4639 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4641 /* Hack -- acquire "broken" flag */
4642 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4644 /* Hack -- acquire "cursed" flag */
4645 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4646 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4647 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4648 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4649 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4650 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4658 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4659 * Hack -- determine if a template is "good"
4660 * @param k_idx 判定したいベースアイテムのID
4661 * @return ベースアイテムが上質ならばTRUEを返す。
4663 static bool kind_is_good(int k_idx)
4665 object_kind *k_ptr = &k_info[k_idx];
4667 /* Analyze the item type */
4668 switch (k_ptr->tval)
4670 /* Armor -- Good unless damaged */
4681 if (k_ptr->to_a < 0) return (FALSE);
4685 /* Weapons -- Good unless damaged */
4692 if (k_ptr->to_h < 0) return (FALSE);
4693 if (k_ptr->to_d < 0) return (FALSE);
4697 /* Ammo -- Arrows/Bolts are good */
4704 /* Books -- High level books are good (except Arcane books) */
4706 case TV_SORCERY_BOOK:
4707 case TV_NATURE_BOOK:
4712 case TV_DAEMON_BOOK:
4713 case TV_CRUSADE_BOOK:
4715 case TV_HISSATSU_BOOK:
4718 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4722 /* Rings -- Rings of Speed are good */
4725 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4726 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4730 /* Amulets -- Amulets of the Magi and Resistance are good */
4733 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4734 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4739 /* Assume not good */
4744 * @brief 生成階に応じたベースアイテムの生成を行う。
4745 * Attempt to make an object (normal or good/great)
4746 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4747 * @param mode オプションフラグ
4748 * @return 生成に成功したらTRUEを返す。
4750 * This routine plays nasty games to generate the "special artifacts".\n
4751 * This routine uses "object_level" for the "generation level".\n
4752 * We assume that the given object has been "wiped".\n
4754 bool make_object(object_type *j_ptr, u32b mode)
4760 /* Chance of "special object" */
4761 prob = ((mode & AM_GOOD) ? 10 : 1000);
4763 /* Base level for the object */
4764 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4767 /* Generate a special object, or a normal object */
4768 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4773 if ((mode & AM_GOOD) && !get_obj_num_hook)
4775 /* Activate restriction (if already specified, use that) */
4776 get_obj_num_hook = kind_is_good;
4779 /* Restricted objects - prepare allocation table */
4780 if (get_obj_num_hook) get_obj_num_prep();
4782 /* Pick a random object */
4783 k_idx = get_obj_num(base);
4785 /* Restricted objects */
4786 if (get_obj_num_hook)
4788 /* Clear restriction */
4789 get_obj_num_hook = NULL;
4791 /* Reset allocation table to default */
4795 /* Handle failure */
4796 if (!k_idx) return (FALSE);
4798 /* Prepare the object */
4799 object_prep(j_ptr, k_idx);
4802 /* Apply magic (allow artifacts) */
4803 apply_magic(j_ptr, object_level, mode);
4805 /* Hack -- generate multiple spikes/missiles */
4806 switch (j_ptr->tval)
4814 j_ptr->number = (byte)damroll(6, 7);
4818 obj_level = k_info[j_ptr->k_idx].level;
4819 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4821 if (cheat_peek) object_mention(j_ptr);
4829 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4830 * Attempt to place an object (normal or good/great) at the given location.
4831 * @param y 配置したいフロアのY座標
4832 * @param x 配置したいフロアのX座標
4833 * @param mode オプションフラグ
4834 * @return 生成に成功したらTRUEを返す。
4836 * This routine plays nasty games to generate the "special artifacts".\n
4837 * This routine uses "object_level" for the "generation level".\n
4838 * This routine requires a clean floor grid destination.\n
4840 void place_object(POSITION y, POSITION x, u32b mode)
4845 cave_type *c_ptr = &cave[y][x];
4851 /* Paranoia -- check bounds */
4852 if (!in_bounds(y, x)) return;
4854 /* Require floor space */
4855 if (!cave_drop_bold(y, x)) return;
4857 /* Avoid stacking on other objects */
4858 if (c_ptr->o_idx) return;
4861 /* Get local object */
4864 /* Wipe the object */
4867 /* Make an object (if possible) */
4868 if (!make_object(q_ptr, mode)) return;
4871 /* Make an object */
4879 /* Acquire object */
4880 o_ptr = &o_list[o_idx];
4882 /* Structure Copy */
4883 object_copy(o_ptr, q_ptr);
4890 o_ptr->next_o_idx = c_ptr->o_idx;
4892 /* Place the object */
4893 c_ptr->o_idx = o_idx;
4903 /* Hack -- Preserve artifacts */
4904 if (object_is_fixed_artifact(q_ptr))
4906 a_info[q_ptr->name1].cur_num = 0;
4913 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4914 * Make a treasure object
4915 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4916 * @return 生成に成功したらTRUEを返す。
4918 * The location must be a legal, clean, floor grid.
4920 bool make_gold(object_type *j_ptr)
4927 /* Hack -- Pick a Treasure variety */
4928 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4930 /* Apply "extra" magic */
4931 if (one_in_(GREAT_OBJ))
4933 i += randint1(object_level + 1);
4936 /* Hack -- Creeping Coins only generate "themselves" */
4937 if (coin_type) i = coin_type;
4939 /* Do not create "illegal" Treasure Types */
4940 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4942 /* Prepare a gold object */
4943 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4945 /* Hack -- Base coin cost */
4946 base = k_info[OBJ_GOLD_LIST+i].cost;
4948 /* Determine how much the treasure is "worth" */
4949 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4957 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
4958 * Places a treasure (Gold or Gems) at given location
4959 * @param y 配置したいフロアのY座標
4960 * @param x 配置したいフロアのX座標
4961 * @return 生成に成功したらTRUEを返す。
4963 * The location must be a legal, clean, floor grid.
4965 void place_gold(POSITION y, POSITION x)
4970 cave_type *c_ptr = &cave[y][x];
4977 /* Paranoia -- check bounds */
4978 if (!in_bounds(y, x)) return;
4980 /* Require floor space */
4981 if (!cave_drop_bold(y, x)) return;
4983 /* Avoid stacking on other objects */
4984 if (c_ptr->o_idx) return;
4987 /* Get local object */
4990 /* Wipe the object */
4993 /* Make some gold */
4994 if (!make_gold(q_ptr)) return;
4997 /* Make an object */
5005 /* Acquire object */
5006 o_ptr = &o_list[o_idx];
5008 /* Copy the object */
5009 object_copy(o_ptr, q_ptr);
5016 o_ptr->next_o_idx = c_ptr->o_idx;
5018 /* Place the object */
5019 c_ptr->o_idx = o_idx;
5031 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5032 * Let an object fall to the ground at or near a location.
5033 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5034 * @param chance ドロップの成功率(%)
5035 * @param y 配置したいフロアのY座標
5036 * @param x 配置したいフロアのX座標
5037 * @return 生成に成功したらTRUEを返す。
5039 * The initial location is assumed to be "in_bounds()".\n
5041 * This function takes a parameter "chance". This is the percentage\n
5042 * chance that the item will "disappear" instead of drop. If the object\n
5043 * has been thrown, then this is the chance of disappearance on contact.\n
5045 * Hack -- this function uses "chance" to determine if it should produce\n
5046 * some form of "description" of the drop event (under the player).\n
5048 * We check several locations to see if we can find a location at which\n
5049 * the object can combine, stack, or be placed. Artifacts will try very\n
5050 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5052 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5063 s16b this_o_idx, next_o_idx = 0;
5067 char o_name[MAX_NLEN];
5073 /* Extract plural */
5074 bool plural = (j_ptr->number != 1);
5077 /* Describe object */
5078 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5081 /* Handle normal "breakage" */
5082 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5086 msg_format("%sは消えた。", o_name);
5088 msg_format("The %s disappear%s.",
5089 o_name, (plural ? "" : "s"));
5094 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5111 /* Scan local grids */
5112 for (dy = -3; dy <= 3; dy++)
5114 /* Scan local grids */
5115 for (dx = -3; dx <= 3; dx++)
5119 /* Calculate actual distance */
5120 d = (dy * dy) + (dx * dx);
5122 /* Ignore distant grids */
5123 if (d > 10) continue;
5129 /* Skip illegal grids */
5130 if (!in_bounds(ty, tx)) continue;
5132 /* Require line of projection */
5133 if (!projectable(y, x, ty, tx)) continue;
5136 c_ptr = &cave[ty][tx];
5138 /* Require floor space */
5139 if (!cave_drop_bold(ty, tx)) continue;
5144 /* Scan objects in that grid */
5145 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5149 /* Acquire object */
5150 o_ptr = &o_list[this_o_idx];
5152 /* Acquire next object */
5153 next_o_idx = o_ptr->next_o_idx;
5155 /* Check for possible combination */
5156 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5162 /* Add new object */
5166 if (k > 99) continue;
5168 /* Calculate score */
5169 s = 1000 - (d + k * 5);
5171 /* Skip bad values */
5172 if (s < bs) continue;
5174 /* New best value */
5177 /* Apply the randomizer to equivalent values */
5178 if ((++bn >= 2) && !one_in_(bn)) continue;
5193 /* Handle lack of space */
5194 if (!flag && !object_is_artifact(j_ptr))
5198 msg_format("%sは消えた。", o_name);
5200 msg_format("The %s disappear%s.",
5201 o_name, (plural ? "" : "s"));
5206 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5214 for (i = 0; !flag && (i < 1000); i++)
5217 ty = rand_spread(by, 1);
5218 tx = rand_spread(bx, 1);
5220 /* Verify location */
5221 if (!in_bounds(ty, tx)) continue;
5223 /* Bounce to that location */
5227 /* Require floor space */
5228 if (!cave_drop_bold(by, bx)) continue;
5237 int candidates = 0, pick;
5239 for (ty = 1; ty < cur_hgt - 1; ty++)
5241 for (tx = 1; tx < cur_wid - 1; tx++)
5243 /* A valid space found */
5244 if (cave_drop_bold(ty, tx)) candidates++;
5248 /* No valid place! */
5253 msg_format("%sは消えた。", o_name);
5255 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5259 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5261 /* Mega-Hack -- preserve artifacts */
5264 /* Hack -- Preserve unknown artifacts */
5265 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5267 /* Mega-Hack -- Preserve the artifact */
5268 a_info[j_ptr->name1].cur_num = 0;
5276 /* Choose a random one */
5277 pick = randint1(candidates);
5279 for (ty = 1; ty < cur_hgt - 1; ty++)
5281 for (tx = 1; tx < cur_wid - 1; tx++)
5283 if (cave_drop_bold(ty, tx))
5287 /* Is this a picked one? */
5301 c_ptr = &cave[by][bx];
5303 /* Scan objects in that grid for combination */
5304 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5308 /* Acquire object */
5309 o_ptr = &o_list[this_o_idx];
5311 /* Acquire next object */
5312 next_o_idx = o_ptr->next_o_idx;
5314 /* Check for combination */
5315 if (object_similar(o_ptr, j_ptr))
5317 /* Combine the items */
5318 object_absorb(o_ptr, j_ptr);
5328 /* Get new object */
5329 if (!done) o_idx = o_pop();
5332 if (!done && !o_idx)
5336 msg_format("%sは消えた。", o_name);
5338 msg_format("The %s disappear%s.",
5339 o_name, (plural ? "" : "s"));
5344 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5346 /* Hack -- Preserve artifacts */
5347 if (object_is_fixed_artifact(j_ptr))
5349 a_info[j_ptr->name1].cur_num = 0;
5359 /* Structure copy */
5360 object_copy(&o_list[o_idx], j_ptr);
5362 /* Access new object */
5363 j_ptr = &o_list[o_idx];
5370 j_ptr->held_m_idx = 0;
5373 j_ptr->next_o_idx = c_ptr->o_idx;
5375 /* Place the object */
5376 c_ptr->o_idx = o_idx;
5391 /* Mega-Hack -- no message if "dropped" by player */
5392 /* Message when an object falls under the player */
5393 if (chance && player_bold(by, bx))
5395 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5407 * Scatter some "great" objects near the player
5408 * @param y1 配置したいフロアのY座標
5409 * @param x1 配置したいフロアのX座標
5410 * @param num 獲得の処理回数
5411 * @param great TRUEならば必ず高級品以上を落とす
5412 * @param special TRUEならば必ず特別品を落とす
5413 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5416 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5419 object_type object_type_body;
5420 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5425 /* Get local object */
5426 i_ptr = &object_type_body;
5428 /* Wipe the object */
5431 /* Make a good (or great) object (if possible) */
5432 if (!make_object(i_ptr, mode)) continue;
5436 object_aware(i_ptr);
5437 object_known(i_ptr);
5440 /* Drop the object */
5441 (void)drop_near(i_ptr, -1, y1, x1);
5446 * Scatter some "amusing" objects near the player
5449 #define AMS_NOTHING 0x00 /* No restriction */
5450 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5451 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5452 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5453 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5463 amuse_type amuse_info[] =
5465 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5466 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5467 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5468 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5469 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5470 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5471 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5472 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5473 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5474 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5475 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5476 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5477 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5484 * @param y1 配置したいフロアのY座標
5485 * @param x1 配置したいフロアのX座標
5486 * @param num 誰得の処理回数
5487 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5490 void amusement(int y1, int x1, int num, bool known)
5493 object_type object_type_body;
5496 for (n = 0; amuse_info[n].tval != 0; n++)
5498 t += amuse_info[n].prob;
5504 int i, k_idx, a_idx = 0;
5505 int r = randint0(t);
5506 bool insta_art, fixed_art;
5510 r -= amuse_info[i].prob;
5514 /* Get local object */
5515 i_ptr = &object_type_body;
5517 /* Wipe the object */
5520 /* Wipe the object */
5521 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5523 /* Paranoia - reroll if nothing */
5524 if (!k_idx) continue;
5526 /* Search an artifact index if need */
5527 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5528 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5530 if (insta_art || fixed_art)
5532 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5534 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5535 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5536 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5537 if (a_info[a_idx].cur_num > 0) continue;
5541 if (a_idx >= max_a_idx) continue;
5544 /* Make an object (if possible) */
5545 object_prep(i_ptr, k_idx);
5546 if (a_idx) i_ptr->name1 = a_idx;
5547 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5549 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5551 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5554 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5555 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5559 object_aware(i_ptr);
5560 object_known(i_ptr);
5563 /* Paranoia - reroll if nothing */
5564 if (!(i_ptr->k_idx)) continue;
5566 /* Drop the object */
5567 (void)drop_near(i_ptr, -1, y1, x1);
5574 #define MAX_NORMAL_TRAPS 18
5576 /* See init_feat_variables() in init2.c */
5577 static s16b normal_traps[MAX_NORMAL_TRAPS];
5580 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5583 void init_normal_traps(void)
5587 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5588 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5589 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5590 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5591 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5592 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5593 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5594 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5595 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5596 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5597 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5598 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5599 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5600 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5601 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5602 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5603 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5604 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5608 * @brief 基本トラップをランダムに選択する /
5610 * @return 選択したトラップのID
5612 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5613 * That is, it does not make sense to have spiked pits at 50 feet.\n
5614 * Actually, it is not this routine, but the "trap instantiation"\n
5615 * code, which should also check for "trap doors" on quest levels.\n
5617 s16b choose_random_trap(void)
5624 /* Hack -- pick a trap */
5625 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5627 /* Accept non-trapdoors */
5628 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5630 /* Hack -- no trap doors on special levels */
5631 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5633 /* Hack -- no trap doors on the deepest level */
5634 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5643 * @brief マスに存在するトラップを秘匿する /
5644 * Disclose an invisible trap
5645 * @param y 秘匿したいマスのY座標
5646 * @param x 秘匿したいマスのX座標
5649 void disclose_grid(int y, int x)
5651 cave_type *c_ptr = &cave[y][x];
5653 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5655 /* No longer hidden */
5656 cave_alter_feat(y, x, FF_SECRET);
5658 else if (c_ptr->mimic)
5660 /* No longer hidden */
5672 * @brief マスをトラップを配置する /
5673 * The location must be a legal, naked, floor grid.
5674 * @param y 配置したいマスのY座標
5675 * @param x 配置したいマスのX座標
5677 * Note that all traps start out as "invisible" and "untyped", and then\n
5678 * when they are "discovered" (by detecting them or setting them off),\n
5679 * the trap is "instantiated" as a visible, "typed", trap.\n
5681 void place_trap(int y, int x)
5683 cave_type *c_ptr = &cave[y][x];
5685 /* Paranoia -- verify location */
5686 if (!in_bounds(y, x)) return;
5688 /* Require empty, clean, floor grid */
5689 if (!cave_clean_bold(y, x)) return;
5691 /* Place an invisible trap */
5692 c_ptr->mimic = c_ptr->feat;
5693 c_ptr->feat = choose_random_trap();
5697 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5698 * Describe the charges on an item in the inventory.
5699 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5702 void inven_item_charges(int item)
5704 object_type *o_ptr = &inventory[item];
5706 /* Require staff/wand */
5707 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5709 /* Require known item */
5710 if (!object_is_known(o_ptr)) return;
5713 if (o_ptr->pval <= 0)
5715 msg_print("もう魔力が残っていない。");
5719 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5722 /* Multiple charges */
5723 if (o_ptr->pval != 1)
5725 /* Print a message */
5726 msg_format("You have %d charges remaining.", o_ptr->pval);
5732 /* Print a message */
5733 msg_format("You have %d charge remaining.", o_ptr->pval);
5740 * @brief アイテムの残り所持数メッセージを表示する /
5741 * Describe an item in the inventory.
5742 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5745 void inven_item_describe(int item)
5747 object_type *o_ptr = &inventory[item];
5748 char o_name[MAX_NLEN];
5750 /* Get a description */
5751 object_desc(o_name, o_ptr, 0);
5753 /* Print a message */
5755 /* "no more" の場合はこちらで表示する */
5756 if (o_ptr->number <= 0)
5758 /*FIRST*//*ここはもう通らないかも */
5759 msg_format("もう%sを持っていない。", o_name);
5763 /* アイテム名を英日切り替え機能対応 */
5764 msg_format("まだ %sを持っている。", o_name);
5767 msg_format("You have %s.", o_name);
5773 * @brief アイテムの残り所持数メッセージを表示する /
5774 * Increase the "number" of an item in the inventory
5775 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5779 void inven_item_increase(int item, int num)
5781 object_type *o_ptr = &inventory[item];
5784 num += o_ptr->number;
5787 if (num > 255) num = 255;
5788 else if (num < 0) num = 0;
5791 num -= (ITEM_NUMBER)o_ptr->number;
5793 /* Change the number and weight */
5796 /* Add the number */
5797 o_ptr->number += num;
5799 /* Add the weight */
5800 p_ptr->total_weight += (num * o_ptr->weight);
5802 /* Recalculate bonuses */
5803 p_ptr->update |= (PU_BONUS);
5805 /* Recalculate mana XXX */
5806 p_ptr->update |= (PU_MANA);
5808 /* Combine the pack */
5809 p_ptr->notice |= (PN_COMBINE);
5812 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5814 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5815 if (!o_ptr->number && p_ptr->ele_attack)
5817 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5819 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5821 /* Clear all temporary elemental brands */
5822 set_ele_attack(0, 0);
5830 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5831 * Erase an inventory slot if it has no more items
5832 * @param item 消去したいプレイヤーのアイテム所持スロット
5835 void inven_item_optimize(int item)
5837 object_type *o_ptr = &inventory[item];
5839 /* Only optimize real items */
5840 if (!o_ptr->k_idx) return;
5842 /* Only optimize empty items */
5843 if (o_ptr->number) return;
5845 /* The item is in the pack */
5846 if (item < INVEN_RARM)
5853 /* Slide everything down */
5854 for (i = item; i < INVEN_PACK; i++)
5856 /* Structure copy */
5857 inventory[i] = inventory[i+1];
5860 /* Erase the "final" slot */
5861 object_wipe(&inventory[i]);
5864 p_ptr->window |= (PW_INVEN);
5867 /* The item is being wielded */
5873 /* Erase the empty slot */
5874 object_wipe(&inventory[item]);
5876 /* Recalculate bonuses */
5877 p_ptr->update |= (PU_BONUS);
5879 /* Recalculate torch */
5880 p_ptr->update |= (PU_TORCH);
5882 /* Recalculate mana XXX */
5883 p_ptr->update |= (PU_MANA);
5886 p_ptr->window |= (PW_EQUIP);
5890 p_ptr->window |= (PW_SPELL);
5894 * @brief 床上の魔道具の残り残量メッセージを表示する /
5895 * Describe the charges on an item on the floor.
5896 * @param item メッセージの対象にしたいアイテム所持スロット
5899 void floor_item_charges(int item)
5901 object_type *o_ptr = &o_list[item];
5903 /* Require staff/wand */
5904 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5906 /* Require known item */
5907 if (!object_is_known(o_ptr)) return;
5910 if (o_ptr->pval <= 0)
5912 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5916 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5919 /* Multiple charges */
5920 if (o_ptr->pval != 1)
5922 /* Print a message */
5923 msg_format("There are %d charges remaining.", o_ptr->pval);
5929 /* Print a message */
5930 msg_format("There is %d charge remaining.", o_ptr->pval);
5937 * @brief 床上のアイテムの残り数メッセージを表示する /
5938 * Describe the charges on an item on the floor.
5939 * @param item メッセージの対象にしたいアイテム所持スロット
5942 void floor_item_describe(int item)
5944 object_type *o_ptr = &o_list[item];
5945 char o_name[MAX_NLEN];
5947 /* Get a description */
5948 object_desc(o_name, o_ptr, 0);
5950 /* Print a message */
5952 /* "no more" の場合はこちらで表示を分ける */
5953 if (o_ptr->number <= 0)
5955 msg_format("床上には、もう%sはない。", o_name);
5959 msg_format("床上には、まだ %sがある。", o_name);
5962 msg_format("You see %s.", o_name);
5969 * @brief 床上のアイテムの数を増やす /
5970 * Increase the "number" of an item on the floor
5971 * @param item 増やしたいアイテムの所持スロット
5972 * @param num 増やしたいアイテムの数
5975 void floor_item_increase(int item, int num)
5977 object_type *o_ptr = &o_list[item];
5980 num += o_ptr->number;
5983 if (num > 255) num = 255;
5984 else if (num < 0) num = 0;
5987 num -= (int)o_ptr->number;
5989 /* Change the number */
5990 o_ptr->number += (ITEM_NUMBER)num;
5995 * @brief 床上の数の無くなったアイテムスロットを消去する /
5996 * Optimize an item on the floor (destroy "empty" items)
5997 * @param item 消去したいアイテムの所持スロット
6000 void floor_item_optimize(int item)
6002 object_type *o_ptr = &o_list[item];
6004 /* Paranoia -- be sure it exists */
6005 if (!o_ptr->k_idx) return;
6007 /* Only optimize empty items */
6008 if (o_ptr->number) return;
6010 /* Delete the object */
6011 delete_object_idx(item);
6016 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6017 * Check if we have space for an item in the pack without overflow
6018 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6019 * @return 溢れずに済むならTRUEを返す
6021 bool inven_carry_okay(object_type *o_ptr)
6026 if (inven_cnt < INVEN_PACK) return (TRUE);
6029 for (j = 0; j < INVEN_PACK; j++)
6031 object_type *j_ptr = &inventory[j];
6033 /* Skip non-objects */
6034 if (!j_ptr->k_idx) continue;
6036 /* Check if the two items can be combined */
6037 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6045 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6046 * Check if we have space for an item in the pack without overflow
6047 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6048 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6049 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6050 * @return o_ptrの方が上位ならばTRUEを返す。
6052 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6056 /* Use empty slots */
6057 if (!j_ptr->k_idx) return TRUE;
6059 /* Hack -- readable books always come first */
6060 if ((o_ptr->tval == REALM1_BOOK) &&
6061 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6062 if ((j_ptr->tval == REALM1_BOOK) &&
6063 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6065 if ((o_ptr->tval == REALM2_BOOK) &&
6066 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6067 if ((j_ptr->tval == REALM2_BOOK) &&
6068 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6070 /* Objects sort by decreasing type */
6071 if (o_ptr->tval > j_ptr->tval) return TRUE;
6072 if (o_ptr->tval < j_ptr->tval) return FALSE;
6074 /* Non-aware (flavored) items always come last */
6075 /* Can happen in the home */
6076 if (!object_is_aware(o_ptr)) return FALSE;
6077 if (!object_is_aware(j_ptr)) return TRUE;
6079 /* Objects sort by increasing sval */
6080 if (o_ptr->sval < j_ptr->sval) return TRUE;
6081 if (o_ptr->sval > j_ptr->sval) return FALSE;
6083 /* Unidentified objects always come last */
6084 /* Objects in the home can be unknown */
6085 if (!object_is_known(o_ptr)) return FALSE;
6086 if (!object_is_known(j_ptr)) return TRUE;
6088 /* Fixed artifacts, random artifacts and ego items */
6089 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6090 else if (o_ptr->art_name) o_type = 2;
6091 else if (object_is_ego(o_ptr)) o_type = 1;
6094 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6095 else if (j_ptr->art_name) j_type = 2;
6096 else if (object_is_ego(j_ptr)) j_type = 1;
6099 if (o_type < j_type) return TRUE;
6100 if (o_type > j_type) return FALSE;
6102 switch (o_ptr->tval)
6108 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6109 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6115 /* Objects sort by increasing hit/damage bonuses */
6116 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6117 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6120 /* Hack: otherwise identical rods sort by
6121 increasing recharge time --dsb */
6123 if (o_ptr->pval < j_ptr->pval) return TRUE;
6124 if (o_ptr->pval > j_ptr->pval) return FALSE;
6128 /* Objects sort by decreasing value */
6129 return o_value > object_value(j_ptr);
6134 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6135 * Add an item to the players inventory, and return the slot used.
6136 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6137 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6139 * If the new item can combine with an existing item in the inventory,\n
6140 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6141 * the item will be placed into the "proper" location in the inventory.\n
6143 * This function can be used to "over-fill" the player's pack, but only\n
6144 * once, and such an action must trigger the "overflow" code immediately.\n
6145 * Note that when the pack is being "over-filled", the new item must be\n
6146 * placed into the "overflow" slot, and the "overflow" must take place\n
6147 * before the pack is reordered, but (optionally) after the pack is\n
6148 * combined. This may be tricky. See "dungeon.c" for info.\n
6150 * Note that this code must remove any location/stack information\n
6151 * from the object once it is placed into the inventory.\n
6153 s16b inven_carry(object_type *o_ptr)
6161 /* Check for combining */
6162 for (j = 0; j < INVEN_PACK; j++)
6164 j_ptr = &inventory[j];
6166 /* Skip non-objects */
6167 if (!j_ptr->k_idx) continue;
6169 /* Hack -- track last item */
6172 /* Check if the two items can be combined */
6173 if (object_similar(j_ptr, o_ptr))
6175 /* Combine the items */
6176 object_absorb(j_ptr, o_ptr);
6178 /* Increase the weight */
6179 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6181 /* Recalculate bonuses */
6182 p_ptr->update |= (PU_BONUS);
6185 p_ptr->window |= (PW_INVEN);
6194 if (inven_cnt > INVEN_PACK) return (-1);
6196 /* Find an empty slot */
6197 for (j = 0; j <= INVEN_PACK; j++)
6199 j_ptr = &inventory[j];
6201 /* Use it if found */
6202 if (!j_ptr->k_idx) break;
6209 /* Reorder the pack */
6212 /* Get the "value" of the item */
6213 s32b o_value = object_value(o_ptr);
6215 /* Scan every occupied slot */
6216 for (j = 0; j < INVEN_PACK; j++)
6218 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6225 for (k = n; k >= i; k--)
6227 /* Hack -- Slide the item */
6228 object_copy(&inventory[k+1], &inventory[k]);
6231 /* Wipe the empty slot */
6232 object_wipe(&inventory[i]);
6237 object_copy(&inventory[i], o_ptr);
6239 /* Access new object */
6240 j_ptr = &inventory[i];
6243 j_ptr->next_o_idx = 0;
6245 /* Forget monster */
6246 j_ptr->held_m_idx = 0;
6248 /* Forget location */
6249 j_ptr->iy = j_ptr->ix = 0;
6251 /* Player touches it, and no longer marked */
6252 j_ptr->marked = OM_TOUCHED;
6254 /* Increase the weight */
6255 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6257 /* Count the items */
6260 /* Recalculate bonuses */
6261 p_ptr->update |= (PU_BONUS);
6263 /* Combine and Reorder pack */
6264 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6267 p_ptr->window |= (PW_INVEN);
6269 /* Return the slot */
6275 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6276 * Take off (some of) a non-cursed equipment item
6277 * @param item オブジェクトを外したい所持テーブルのID
6279 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6281 * Note that only one item at a time can be wielded per slot.\n
6282 * Note that taking off an item when "full" may cause that item\n
6283 * to fall to the ground.\n
6284 * Return the inventory slot into which the item is placed.\n
6286 s16b inven_takeoff(int item, int amt)
6297 char o_name[MAX_NLEN];
6300 /* Get the item to take off */
6301 o_ptr = &inventory[item];
6304 if (amt <= 0) return (-1);
6307 if (amt > o_ptr->number) amt = o_ptr->number;
6309 /* Get local object */
6312 /* Obtain a local object */
6313 object_copy(q_ptr, o_ptr);
6315 /* Modify quantity */
6316 q_ptr->number = amt;
6318 /* Describe the object */
6319 object_desc(o_name, q_ptr, 0);
6321 /* Took off weapon */
6322 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6323 object_is_melee_weapon(o_ptr))
6325 act = _("を装備からはずした", "You were wielding");
6329 else if (item == INVEN_BOW)
6331 act = _("を装備からはずした", "You were holding");
6334 /* Took off light */
6335 else if (item == INVEN_LITE)
6337 act = _("を光源からはずした", "You were holding");
6340 /* Took off something */
6343 act = _("を装備からはずした", "You were wearing");
6346 /* Modify, Optimize */
6347 inven_item_increase(item, -amt);
6348 inven_item_optimize(item);
6350 /* Carry the object */
6351 slot = inven_carry(q_ptr);
6355 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6357 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6367 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6368 * Drop (some of) a non-cursed inventory/equipment item
6369 * @param item 所持テーブルのID
6370 * @param amt 落としたい個数
6373 * The object will be dropped "near" the current location
6375 void inven_drop(int item, int amt)
6382 char o_name[MAX_NLEN];
6385 /* Access original object */
6386 o_ptr = &inventory[item];
6389 if (amt <= 0) return;
6392 if (amt > o_ptr->number) amt = o_ptr->number;
6395 /* Take off equipment */
6396 if (item >= INVEN_RARM)
6398 /* Take off first */
6399 item = inven_takeoff(item, amt);
6401 /* Access original object */
6402 o_ptr = &inventory[item];
6406 /* Get local object */
6409 /* Obtain local object */
6410 object_copy(q_ptr, o_ptr);
6412 /* Distribute charges of wands or rods */
6413 distribute_charges(o_ptr, q_ptr, amt);
6415 /* Modify quantity */
6416 q_ptr->number = amt;
6418 /* Describe local object */
6419 object_desc(o_name, q_ptr, 0);
6422 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6424 /* Drop it near the player */
6425 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6427 /* Modify, Describe, Optimize */
6428 inven_item_increase(item, -amt);
6429 inven_item_describe(item);
6430 inven_item_optimize(item);
6435 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6436 * Combine items in the pack
6439 * Note special handling of the "overflow" slot
6441 void combine_pack(void)
6446 bool flag = FALSE, combined;
6452 /* Combine the pack (backwards) */
6453 for (i = INVEN_PACK; i > 0; i--)
6456 o_ptr = &inventory[i];
6458 /* Skip empty items */
6459 if (!o_ptr->k_idx) continue;
6461 /* Scan the items above that item */
6462 for (j = 0; j < i; j++)
6467 j_ptr = &inventory[j];
6469 /* Skip empty items */
6470 if (!j_ptr->k_idx) continue;
6473 * Get maximum number of the stack if these
6474 * are similar, get zero otherwise.
6476 max_num = object_similar_part(j_ptr, o_ptr);
6478 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6479 if (max_num && j_ptr->number < max_num)
6481 if (o_ptr->number + j_ptr->number <= max_num)
6486 /* Add together the item counts */
6487 object_absorb(j_ptr, o_ptr);
6489 /* One object is gone */
6492 /* Slide everything down */
6493 for (k = i; k < INVEN_PACK; k++)
6495 /* Structure copy */
6496 inventory[k] = inventory[k+1];
6499 /* Erase the "final" slot */
6500 object_wipe(&inventory[k]);
6504 int old_num = o_ptr->number;
6505 int remain = j_ptr->number + o_ptr->number - max_num;
6507 o_ptr->number -= remain;
6509 /* Add together the item counts */
6510 object_absorb(j_ptr, o_ptr);
6512 o_ptr->number = remain;
6514 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6515 if (o_ptr->tval == TV_ROD)
6517 o_ptr->pval = o_ptr->pval * remain / old_num;
6518 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6521 /* Hack -- if wands are stacking, combine the charges. -LM- */
6522 if (o_ptr->tval == TV_WAND)
6524 o_ptr->pval = o_ptr->pval * remain / old_num;
6529 p_ptr->window |= (PW_INVEN);
6543 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6547 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6548 * Reorder items in the pack
6551 * Note special handling of the "overflow" slot
6553 void reorder_pack(void)
6563 /* Re-order the pack (forwards) */
6564 for (i = 0; i < INVEN_PACK; i++)
6566 /* Mega-Hack -- allow "proper" over-flow */
6567 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6570 o_ptr = &inventory[i];
6572 /* Skip empty slots */
6573 if (!o_ptr->k_idx) continue;
6575 /* Get the "value" of the item */
6576 o_value = object_value(o_ptr);
6578 /* Scan every occupied slot */
6579 for (j = 0; j < INVEN_PACK; j++)
6581 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6584 /* Never move down */
6585 if (j >= i) continue;
6590 /* Get local object */
6593 /* Save a copy of the moving item */
6594 object_copy(q_ptr, &inventory[i]);
6596 /* Slide the objects */
6597 for (k = i; k > j; k--)
6599 /* Slide the item */
6600 object_copy(&inventory[k], &inventory[k-1]);
6603 /* Insert the moving item */
6604 object_copy(&inventory[j], q_ptr);
6607 p_ptr->window |= (PW_INVEN);
6611 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6615 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6616 * Hack -- display an object kind in the current window
6617 * @param k_idx ベースアイテムの参照ID
6620 * Include list of usable spells for readible books
6622 void display_koff(int k_idx)
6631 char o_name[MAX_NLEN];
6634 /* Erase the window */
6635 for (y = 0; y < Term->hgt; y++)
6637 /* Erase the line */
6638 Term_erase(0, y, 255);
6644 /* Get local object */
6647 /* Prepare the object */
6648 object_prep(q_ptr, k_idx);
6651 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6653 /* Mention the object name */
6654 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6656 /* Access the item's sval */
6658 use_realm = tval2realm(q_ptr->tval);
6660 /* Warriors are illiterate */
6661 if (p_ptr->realm1 || p_ptr->realm2)
6663 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6667 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6668 if (!is_magic(use_realm)) return;
6669 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6672 /* Display spells in readible books */
6678 /* Extract spells */
6679 for (spell = 0; spell < 32; spell++)
6681 /* Check for this spell */
6682 if (fake_spell_flags[sval] & (1L << spell))
6684 /* Collect this spell */
6685 spells[num++] = spell;
6690 print_spells(0, spells, num, 2, 0, use_realm);
6695 * @brief 警告を放つアイテムを選択する /
6696 * Choose one of items that have warning flag
6697 * Calculate spell damages
6700 object_type *choose_warning_item(void)
6703 int choices[INVEN_TOTAL - INVEN_RARM];
6706 /* Paranoia -- Player has no warning ability */
6707 if (!p_ptr->warning) return NULL;
6709 /* Search Inventory */
6710 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6712 u32b flgs[TR_FLAG_SIZE];
6713 object_type *o_ptr = &inventory[i];
6715 object_flags(o_ptr, flgs);
6716 if (have_flag(flgs, TR_WARNING))
6718 choices[number] = i;
6723 /* Choice one of them */
6724 return number ? &inventory[choices[randint0(number)]] : NULL;
6728 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6729 * Calculate spell damages
6730 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6731 * @param typ 効果属性のID
6733 * @param max 算出した最大ダメージを返すポインタ
6736 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int *max)
6738 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6739 int rlev = r_ptr->level;
6740 bool ignore_wraith_form = FALSE;
6742 /* Vulnerability, resistance and immunity */
6746 if (p_ptr->immune_elec)
6749 ignore_wraith_form = TRUE;
6753 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6754 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6755 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6756 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6757 if (IS_OPPOSE_ELEC())
6758 dam = (dam + 2) / 3;
6763 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6764 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6768 if (p_ptr->immune_acid)
6771 ignore_wraith_form = TRUE;
6775 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6776 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6777 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6778 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6784 if (p_ptr->immune_cold)
6787 ignore_wraith_form = TRUE;
6791 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6792 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6793 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6794 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6799 if (p_ptr->immune_fire)
6802 ignore_wraith_form = TRUE;
6806 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6807 if (prace_is_(RACE_ENT)) dam += dam / 3;
6808 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6809 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6810 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6815 ignore_wraith_form = TRUE;
6819 if (!p_ptr->blind &&
6820 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6821 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6824 ignore_wraith_form = TRUE;
6829 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6830 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6831 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6834 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6835 * "dam *= 2;" for later "dam /= 2"
6837 if (p_ptr->wraith_form) dam *= 2;
6841 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6844 ignore_wraith_form = TRUE;
6846 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6850 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6854 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6858 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6862 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6866 if (prace_is_(RACE_SPECTRE))
6869 ignore_wraith_form = TRUE;
6871 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6875 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6879 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6883 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6887 if (p_ptr->levitation) dam = (dam * 2) / 3;
6891 if (p_ptr->resist_shard) dam /= 2;
6895 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6896 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6900 if (p_ptr->mimic_form)
6902 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6905 ignore_wraith_form = TRUE;
6910 switch (p_ptr->prace)
6919 ignore_wraith_form = TRUE;
6926 if (p_ptr->align > 10) dam /= 2;
6927 else if (p_ptr->align < -10) dam *= 2;
6931 if (p_ptr->align > 10) dam *= 2;
6935 case GF_BRAIN_SMASH:
6936 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6939 ignore_wraith_form = TRUE;
6947 if (100 + rlev / 2 <= p_ptr->skill_sav)
6950 ignore_wraith_form = TRUE;
6955 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6958 ignore_wraith_form = TRUE;
6963 if (p_ptr->wraith_form && !ignore_wraith_form)
6969 if (dam > *max) *max = dam;
6973 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6974 * Calculate spell damages
6975 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6976 * @param typ 効果属性のID
6977 * @param m_idx 魔法を行使するモンスターのID
6978 * @param max 算出した最大ダメージを返すポインタ
6981 void spell_damcalc_by_spellnum(int spell_num, int typ, int m_idx, int *max)
6983 monster_type *m_ptr = &m_list[m_idx];
6984 int dam = monspell_damage((spell_num), m_idx, DAM_MAX);
6985 spell_damcalc(m_ptr, typ, dam, max);
6989 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
6990 * Calculate blow damages
6991 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
6992 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
6993 * @return 算出された最大ダメージを返す。
6995 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6997 int dam = blow_ptr->d_dice * blow_ptr->d_side;
6999 bool check_wraith_form = TRUE;
7001 if (blow_ptr->method != RBM_EXPLODE)
7003 int ac = p_ptr->ac + p_ptr->to_a;
7005 switch (blow_ptr->effect)
7009 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7010 dam = MAX(dam, tmp_dam * 2);
7016 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7020 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7022 check_wraith_form = FALSE;
7026 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7028 check_wraith_form = FALSE;
7032 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7034 check_wraith_form = FALSE;
7038 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7040 check_wraith_form = FALSE;
7045 check_wraith_form = FALSE;
7049 if (check_wraith_form && p_ptr->wraith_form)
7057 dam = (dam + 1) / 2;
7058 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7066 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7067 * Examine the grid (xx,yy) and warn the player if there are any danger
7068 * @param xx 危険性を調査するマスのX座標
7069 * @param yy 危険性を調査するマスのY座標
7070 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7072 bool process_warning(int xx, int yy)
7076 char o_name[MAX_NLEN];
7078 #define WARNING_AWARE_RANGE 12
7080 static int old_damage = 0;
7082 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7084 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7087 monster_type *m_ptr;
7088 monster_race *r_ptr;
7090 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7092 c_ptr = &cave[my][mx];
7094 if (!c_ptr->m_idx) continue;
7096 m_ptr = &m_list[c_ptr->m_idx];
7098 if (MON_CSLEEP(m_ptr)) continue;
7099 if (!is_hostile(m_ptr)) continue;
7101 r_ptr = &r_info[m_ptr->r_idx];
7103 /* Monster spells (only powerful ones)*/
7104 if (projectable(my, mx, yy, xx))
7106 u32b f4 = r_ptr->flags4;
7107 u32b f5 = r_ptr->a_ability_flags1;
7108 u32b f6 = r_ptr->a_ability_flags2;
7110 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7112 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7113 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7114 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7115 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7116 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7117 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7119 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7120 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7121 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7122 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7123 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7124 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7125 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7126 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7127 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7128 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7129 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7130 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7131 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7132 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7133 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7134 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7135 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7136 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7137 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7138 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7139 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7140 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7141 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7144 /* Monster melee attacks */
7145 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7147 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7151 for (m = 0; m < 4; m++)
7153 /* Skip non-attacks */
7154 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7156 /* Extract the attack info */
7157 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7158 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7160 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7164 /* Contribution from this monster */
7165 dam_max += dam_max0;
7169 /* Prevent excessive warning */
7170 if (dam_max > old_damage)
7172 old_damage = dam_max * 3 / 2;
7174 if (dam_max > p_ptr->chp / 2)
7176 object_type *o_ptr = choose_warning_item();
7179 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7181 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7182 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7185 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7188 else old_damage = old_damage / 2;
7190 c_ptr = &cave[yy][xx];
7191 if (((!easy_disarm && is_trap(c_ptr->feat))
7192 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7194 object_type *o_ptr = choose_warning_item();
7197 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7199 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7200 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7202 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7209 * @brief エッセンスの付加可能な武器や矢弾かを返す
7210 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7211 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7213 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7215 switch (o_ptr->tval)
7228 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7237 * エッセンス情報の構造体 / A structure for smithing
7240 int add; /* TR flag number or special essence id */
7241 cptr add_name; /* Name of this ability */
7242 int type; /* Menu number */
7243 int essence; /* Index for carrying essences */
7244 int value; /* Needed value to add this ability */
7249 * エッセンス情報テーブル Smithing type data for Weapon smith
7252 static essence_type essence_info[] =
7254 {TR_STR, "腕力", 4, TR_STR, 20},
7255 {TR_INT, "知能", 4, TR_INT, 20},
7256 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7257 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7258 {TR_CON, "耐久力", 4, TR_CON, 20},
7259 {TR_CHR, "魅力", 4, TR_CHR, 20},
7260 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7261 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7262 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7263 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7264 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7265 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7266 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7267 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7268 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7269 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7270 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7271 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7272 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7273 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7274 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7275 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7276 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7277 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7278 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7279 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7280 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7281 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7282 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7283 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7284 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7285 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7286 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7287 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7288 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7289 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7290 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7291 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7292 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7293 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7294 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7295 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7296 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7297 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7298 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7299 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7300 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7301 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7302 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7303 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7304 {TR_SH_FIRE, "", 0, -2, 0},
7305 {TR_SH_ELEC, "", 0, -2, 0},
7306 {TR_SH_COLD, "", 0, -2, 0},
7307 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7308 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7309 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7310 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7311 {TR_LITE_2, "", 0, -2, 0},
7312 {TR_LITE_3, "", 0, -2, 0},
7313 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7314 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7315 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7316 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7317 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7319 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7320 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7321 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7322 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7323 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7324 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7325 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7326 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7327 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7328 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7329 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7330 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7331 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7332 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7333 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7334 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7335 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7336 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7338 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7339 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7340 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7341 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7342 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7343 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7344 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7345 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7347 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7348 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7349 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7350 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7351 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7352 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7353 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7354 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7355 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7356 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7357 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7358 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7360 {-1, NULL, 0, -1, 0}
7363 static essence_type essence_info[] =
7365 {TR_STR, "strength", 4, TR_STR, 20},
7366 {TR_INT, "intelligence", 4, TR_INT, 20},
7367 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7368 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7369 {TR_CON, "constitution", 4, TR_CON, 20},
7370 {TR_CHR, "charisma", 4, TR_CHR, 20},
7371 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7372 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7373 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7374 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7375 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7376 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7377 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7378 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7379 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7380 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7381 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7382 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7383 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7384 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7385 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7386 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7387 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7388 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7389 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7390 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7391 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7392 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7393 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7394 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7395 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7396 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7397 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7398 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7399 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7400 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7401 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7402 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7403 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7404 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7405 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7406 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7407 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7408 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7409 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7410 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7411 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7412 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7413 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7414 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7415 {TR_SH_FIRE, "", 0, -2, 0},
7416 {TR_SH_ELEC, "", 0, -2, 0},
7417 {TR_SH_COLD, "", 0, -2, 0},
7418 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7419 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7420 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7421 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7422 {TR_LITE_2, "", 0, -2, 0},
7423 {TR_LITE_3, "", 0, -2, 0},
7424 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7425 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7426 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7427 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7428 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7430 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7431 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7432 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7433 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7434 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7435 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7436 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7437 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7438 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7439 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7440 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7441 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7442 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7443 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7444 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7445 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7446 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7447 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7449 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7450 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7451 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7452 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7453 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7454 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7455 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7456 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7458 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7459 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7460 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7461 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7462 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7463 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7464 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7465 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7466 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7467 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7468 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7469 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7471 {-1, NULL, 0, -1, 0}
7477 * エッセンス名テーブル / Essense names for Weapon smith
7480 cptr essence_name[] =
7583 cptr essence_name[] =
7686 * @brief 所持しているエッセンス一覧を表示する
7689 static void display_essence(void)
7694 for (i = 1; i < 22; i++)
7698 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7699 "Essence Num Essence Num Essence Num "), 1, 8);
7700 for (i = 0; essence_name[i]; i++)
7702 if (!essence_name[i][0]) continue;
7703 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7706 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7716 static void drain_essence(void)
7718 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7721 bool observe = FALSE;
7722 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7723 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7726 byte iy, ix, marked, number;
7727 s16b next_o_idx, weight;
7729 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7732 item_tester_hook = object_is_weapon_armour_ammo;
7733 item_tester_no_ryoute = TRUE;
7736 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7737 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7739 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7741 /* Get the item (in the pack) */
7744 o_ptr = &inventory[item];
7747 /* Get the item (on the floor) */
7750 o_ptr = &o_list[0 - item];
7753 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7755 char o_name[MAX_NLEN];
7756 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7757 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7760 p_ptr->energy_use = 100;
7762 object_flags(o_ptr, old_flgs);
7763 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7764 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7765 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7766 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7767 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7768 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7769 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7770 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7771 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7773 old_to_a = o_ptr->to_a;
7775 old_to_h = o_ptr->to_h;
7776 old_to_d = o_ptr->to_d;
7779 old_pval = o_ptr->pval;
7780 old_name2 = o_ptr->name2;
7781 old_timeout = o_ptr->timeout;
7782 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7783 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7784 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7785 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7786 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7787 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7788 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7789 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7790 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7791 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7792 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7793 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7794 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7795 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7796 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7797 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7798 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7799 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7800 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7804 next_o_idx = o_ptr->next_o_idx;
7805 marked = o_ptr->marked;
7806 weight = o_ptr->weight;
7807 number = o_ptr->number;
7809 object_prep(o_ptr, o_ptr->k_idx);
7813 o_ptr->next_o_idx=next_o_idx;
7814 o_ptr->marked=marked;
7815 o_ptr->number = number;
7816 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7817 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7818 o_ptr->ident |= (IDENT_MENTAL);
7819 object_aware(o_ptr);
7820 object_known(o_ptr);
7822 object_flags(o_ptr, new_flgs);
7824 for (i = 0; essence_info[i].add_name; i++)
7826 essence_type *es_ptr = &essence_info[i];
7829 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7830 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7832 if (es_ptr->add < TR_FLAG_MAX &&
7833 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7834 have_flag(old_flgs, es_ptr->add))
7838 drain_value[es_ptr->essence] += 10 * pval;
7840 else if (es_ptr->essence != -2)
7842 drain_value[es_ptr->essence] += 10;
7844 else if (es_ptr->add == TR_SH_FIRE)
7846 drain_value[TR_BRAND_FIRE] += 10;
7847 drain_value[TR_RES_FIRE] += 10;
7849 else if (es_ptr->add == TR_SH_ELEC)
7851 drain_value[TR_BRAND_ELEC] += 10;
7852 drain_value[TR_RES_ELEC] += 10;
7854 else if (es_ptr->add == TR_SH_COLD)
7856 drain_value[TR_BRAND_COLD] += 10;
7857 drain_value[TR_RES_COLD] += 10;
7859 else if (es_ptr->add == TR_LITE_2)
7861 drain_value[TR_LITE_1] += 20;
7863 else if (es_ptr->add == TR_LITE_3)
7865 drain_value[TR_LITE_1] += 30;
7870 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7872 drain_value[TR_INT] += 5;
7873 drain_value[TR_WIS] += 5;
7875 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7877 drain_value[TR_BRAND_POIS] += 5;
7878 drain_value[TR_BRAND_ACID] += 5;
7879 drain_value[TR_BRAND_ELEC] += 5;
7880 drain_value[TR_BRAND_FIRE] += 5;
7881 drain_value[TR_BRAND_COLD] += 5;
7883 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7885 drain_value[TR_INT] += 10;
7887 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7889 drain_value[TR_STR] += 10;
7891 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7893 drain_value[TR_DEX] += 10;
7895 if (old_name2 == EGO_2WEAPON)
7897 drain_value[TR_DEX] += 20;
7899 if (object_is_weapon_ammo(o_ptr))
7901 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7903 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7905 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7906 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7907 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7908 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7910 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7912 drain_value[i] *= number;
7913 drain_value[i] = drain_value[i] * dec / 4;
7914 drain_value[i] = MAX(drain_value[i], 0);
7915 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7923 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7927 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7929 for (i = 0; essence_name[i]; i++)
7931 if (!essence_name[i][0]) continue;
7932 if (!drain_value[i]) continue;
7934 p_ptr->magic_num1[i] += drain_value[i];
7935 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7937 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7941 /* Apply autodestroy/inscription to the drained item */
7942 autopick_alter_item(item, TRUE);
7944 /* Combine the pack */
7945 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7948 p_ptr->window |= (PW_INVEN);
7952 * @brief 付加するエッセンスの大別を選択する
7953 * @return 選んだエッセンスの大別ID
7955 static int choose_essence(void)
7959 int menu_line = (use_menu ? 1 : 0);
7962 cptr menu_name[] = {
7972 cptr menu_name[] = {
7982 const int mode_max = 7;
7985 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7988 #endif /* ALLOW_REPEAT */
7997 for (i = 0; i < mode_max; i++)
7999 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8000 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8002 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8003 prt("Choose from menu.", 0, 0);
8022 menu_line += mode_max - 1;
8031 if (menu_line > mode_max) menu_line -= mode_max;
8042 for (i = 0; i < mode_max; i++)
8043 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8045 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8051 if (isupper(choice)) choice = tolower(choice);
8053 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8054 mode = (int)choice - 'a' + 1;
8061 #endif /* ALLOW_REPEAT */
8066 * @brief エッセンスを実際に付加する
8067 * @param mode エッセンスの大別ID
8070 static void add_essence(int mode)
8072 int item, max_num = 0;
8081 char o_name[MAX_NLEN];
8083 essence_type *es_ptr;
8085 int menu_line = (use_menu ? 1 : 0);
8087 for (i = 0; essence_info[i].add_name; i++)
8089 es_ptr = &essence_info[i];
8091 if (es_ptr->type != mode) continue;
8096 if (!repeat_pull(&i) || i<0 || i>=max_num)
8098 #endif /* ALLOW_REPEAT */
8101 /* Nothing chosen yet */
8107 /* Build a prompt */
8108 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8109 if (use_menu) screen_save();
8111 /* Get a spell from the user */
8113 choice = (always_show_list || use_menu) ? ESCAPE:1;
8117 if( choice==ESCAPE ) choice = ' ';
8118 else if( !get_com(out_val, &choice, FALSE) )break;
8120 if (use_menu && choice != ' ')
8134 menu_line += (max_num-1);
8157 menu_line = max_num;
8171 if (menu_line > max_num) menu_line -= max_num;
8173 /* Request redraw */
8174 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8177 if (!redraw || use_menu)
8181 char dummy[80], dummy2[80];
8189 /* Save the screen */
8190 if (!use_menu) screen_save();
8192 for (y = 1; y < 24; y++)
8195 /* Print header(s) */
8197 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8200 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8203 for (ctr = 0; ctr < max_num; ctr++)
8205 es_ptr = &essence_info[num[ctr]];
8209 if (ctr == (menu_line-1))
8210 strcpy(dummy, _("》 ", "> "));
8211 else strcpy(dummy, " ");
8214 /* letter/number for power selection */
8217 sprintf(dummy, "%c) ",I2A(ctr));
8220 strcat(dummy, es_ptr->add_name);
8225 if (es_ptr->essence != -1)
8227 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8228 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8234 case ESSENCE_SH_FIRE:
8235 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8236 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8237 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8239 case ESSENCE_SH_ELEC:
8240 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8241 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8242 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8244 case ESSENCE_SH_COLD:
8245 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8246 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8247 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8249 case ESSENCE_RESISTANCE:
8250 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8251 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8252 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8253 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8254 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8256 case ESSENCE_SUSTAIN:
8257 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8258 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8259 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8260 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8261 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8266 if (!able[ctr]) col = TERM_RED;
8268 if (es_ptr->essence != -1)
8270 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8274 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8277 c_prt(col, dummy2, ctr+2, x);
8287 /* Restore the screen */
8298 ask = (isupper(choice));
8301 if (ask) choice = tolower(choice);
8303 /* Extract request */
8304 i = (islower(choice) ? A2I(choice) : -1);
8307 /* Totally Illegal */
8308 if ((i < 0) || (i >= max_num) || !able[i])
8320 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8322 /* Belay that order */
8323 if (!get_check(tmp_val)) continue;
8330 /* Restore the screen */
8331 if (redraw) screen_load();
8338 #endif /* ALLOW_REPEAT */
8340 es_ptr = &essence_info[num[i]];
8342 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8343 item_tester_tval = TV_GLOVES;
8344 else if (mode == 1 || mode == 5)
8345 item_tester_hook = item_tester_hook_melee_ammo;
8346 else if (es_ptr->add == ESSENCE_ATTACK)
8347 item_tester_hook = object_allow_enchant_weapon;
8348 else if (es_ptr->add == ESSENCE_AC)
8349 item_tester_hook = object_is_armour;
8351 item_tester_hook = object_is_weapon_armour_ammo;
8352 item_tester_no_ryoute = TRUE;
8355 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8356 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8358 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8360 /* Get the item (in the pack) */
8363 o_ptr = &inventory[item];
8366 /* Get the item (on the floor) */
8369 o_ptr = &o_list[0 - item];
8372 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8374 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8378 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8380 use_essence = es_ptr->value;
8381 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8382 if (o_ptr->number > 1)
8384 use_essence *= o_ptr->number;
8385 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8388 if (es_ptr->essence != -1)
8390 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8392 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8395 if (is_pval_flag(es_ptr->add))
8397 if (o_ptr->pval < 0)
8399 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8402 else if (es_ptr->add == TR_BLOWS)
8404 if (o_ptr->pval > 1)
8406 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8410 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8412 else if (o_ptr->pval > 0)
8414 use_essence *= o_ptr->pval;
8415 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8422 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8424 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8425 strcpy(tmp_val, "1");
8427 if (!get_string(tmp, tmp_val, 1)) return;
8428 pval = atoi(tmp_val);
8429 if (pval > limit) pval = limit;
8430 else if (pval < 1) pval = 1;
8431 o_ptr->pval += pval;
8432 use_essence *= pval;
8433 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8436 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8438 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8442 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8446 int get_to_h, get_to_d;
8448 strcpy(tmp_val, "1");
8449 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8450 val = atoi(tmp_val);
8451 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8452 else if (val < 1) val = 1;
8454 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8455 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8457 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8460 get_to_h = ((val+1)/2+randint0(val/2+1));
8461 get_to_d = ((val+1)/2+randint0(val/2+1));
8462 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8463 o_ptr->to_h += get_to_h;
8464 o_ptr->to_d += get_to_d;
8466 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8467 if (es_ptr->add == ESSENCE_ATTACK)
8469 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8471 msg_print(_("改良に失敗した。", "You failed to enchant."));
8472 p_ptr->energy_use = 100;
8477 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8478 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8481 else if (es_ptr->add == ESSENCE_AC)
8483 if (o_ptr->to_a >= p_ptr->lev/5+5)
8485 msg_print(_("改良に失敗した。", "You failed to enchant."));
8486 p_ptr->energy_use = 100;
8491 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8496 o_ptr->xtra3 = es_ptr->add + 1;
8501 bool success = TRUE;
8505 case ESSENCE_SH_FIRE:
8506 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8511 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8512 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8514 case ESSENCE_SH_ELEC:
8515 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8520 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8521 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8523 case ESSENCE_SH_COLD:
8524 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8529 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8530 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8532 case ESSENCE_RESISTANCE:
8533 case ESSENCE_SUSTAIN:
8534 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))
8539 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8540 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8541 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8542 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8547 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8550 if (es_ptr->add == ESSENCE_SUSTAIN)
8552 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8553 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8554 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8555 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8559 o_ptr->xtra3 = es_ptr->add + 1;
8563 p_ptr->energy_use = 100;
8566 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8568 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8571 /* Combine the pack */
8572 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8575 p_ptr->window |= (PW_INVEN);
8582 static void erase_essence(void)
8587 char o_name[MAX_NLEN];
8588 u32b flgs[TR_FLAG_SIZE];
8590 item_tester_hook = object_is_smith;
8593 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8594 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8596 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8598 /* Get the item (in the pack) */
8601 o_ptr = &inventory[item];
8604 /* Get the item (on the floor) */
8607 o_ptr = &o_list[0 - item];
8610 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8611 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8613 p_ptr->energy_use = 100;
8615 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8617 o_ptr->to_h -= (o_ptr->xtra4>>8);
8618 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8620 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8621 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8624 object_flags(o_ptr, flgs);
8625 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8626 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8628 /* Combine the pack */
8629 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8632 p_ptr->window |= (PW_INVEN);
8636 * @brief 鍛冶コマンドのメインルーチン
8637 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8640 void do_cmd_kaji(bool only_browse)
8645 int menu_line = (use_menu ? 1 : 0);
8649 if (p_ptr->confused)
8651 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8656 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8661 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8667 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8669 #endif /* ALLOW_REPEAT */
8671 if (only_browse) screen_save();
8673 if (!only_browse) screen_save();
8679 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8680 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8681 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8682 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8683 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8684 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8686 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8687 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8688 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8689 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8690 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8691 prt(format("Choose command from menu."), 0, 0);
8718 if (menu_line > 5) menu_line -= 5;
8727 prt(" a) エッセンス一覧", 2, 14);
8728 prt(" b) エッセンス抽出", 3, 14);
8729 prt(" c) エッセンス消去", 4, 14);
8730 prt(" d) エッセンス付加", 5, 14);
8731 prt(" e) 武器/防具強化", 6, 14);
8732 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8734 prt(" a) List essences", 2, 14);
8735 prt(" b) Extract essence", 3, 14);
8736 prt(" c) Remove essence", 4, 14);
8737 prt(" d) Add essence", 5, 14);
8738 prt(" e) Enchant weapon/armor", 6, 14);
8739 if (!get_com("Command :", &choice, TRUE))
8776 /* Clear lines, position cursor (really should use strlen here) */
8777 Term_erase(14, 21, 255);
8778 Term_erase(14, 20, 255);
8779 Term_erase(14, 19, 255);
8780 Term_erase(14, 18, 255);
8781 Term_erase(14, 17, 255);
8782 Term_erase(14, 16, 255);
8784 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8785 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8787 prt(&temp[j], line, 15);
8792 if (!only_browse) screen_load();
8793 } while (only_browse);
8797 #endif /* ALLOW_REPEAT */
8801 case 1: display_essence();break;
8802 case 2: drain_essence();break;
8803 case 3: erase_essence();break;
8805 mode = choose_essence();
8810 case 5: add_essence(10);break;
8816 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8817 * Torches have special abilities when they are flaming.
8818 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8819 * @param flgs 特別に追加するフラグを返す参照ポインタ
8822 void torch_flags(object_type *o_ptr, u32b *flgs)
8824 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8826 if (o_ptr->xtra4 > 0)
8828 add_flag(flgs, TR_BRAND_FIRE);
8829 add_flag(flgs, TR_KILL_UNDEAD);
8830 add_flag(flgs, TR_THROW);
8836 * @brief 投擲時たいまつにダイスを与える。
8837 * Torches have special abilities when they are flaming.
8838 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8839 * @param dd 特別なダイス数を返す参照ポインタ
8840 * @param ds 特別なダイス面数を返す参照ポインタ
8843 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8845 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8847 if (o_ptr->xtra4 > 0)
8856 * @brief 投擲時命中したたいまつの寿命を縮める。
8857 * Torches have special abilities when they are flaming.
8858 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8861 void torch_lost_fuel(object_type *o_ptr)
8863 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8865 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8866 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;