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)
350 int cur_lev, cur_dis, chance;
358 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
361 p_ptr->redraw |= (PR_MAP);
364 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
368 /* Compact at least 'size' objects */
369 for (num = 0, cnt = 1; num < size; cnt++)
371 /* Get more vicious each iteration */
374 /* Get closer each iteration */
375 cur_dis = 5 * (20 - cnt);
377 /* Examine the objects */
378 for (i = 1; i < o_max; i++)
382 /* Skip dead objects */
383 if (!o_ptr->k_idx) continue;
385 /* Hack -- High level objects start out "immune" */
386 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
389 if (o_ptr->held_m_idx)
393 /* Acquire monster */
394 m_ptr = &m_list[o_ptr->held_m_idx];
396 /* Get the location */
400 /* Monsters protect their objects */
401 if (randint0(100) < 90) continue;
407 /* Get the location */
412 /* Nearby objects start out "immune" */
413 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
418 /* Hack -- only compact artifacts in emergencies */
419 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
420 (cnt < 1000)) chance = 100;
422 /* Apply the saving throw */
423 if (randint0(100) < chance) continue;
425 /* Delete the object */
426 delete_object_idx(i);
434 /* Excise dead objects (backwards!) */
435 for (i = o_max - 1; i >= 1; i--)
439 /* Skip real objects */
440 if (o_ptr->k_idx) continue;
442 /* Move last object into open hole */
443 compact_objects_aux(o_max - 1, i);
445 /* Compress "o_max" */
452 * @brief グローバルオブジェクト配列を初期化する /
453 * Delete all the items when player leaves the level
454 * @note we do NOT visually reflect these (irrelevant) changes
456 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
457 * and the "m_ptr->next_o_idx" field for every monster, since
458 * we know we are clearing every object. Technically, we only
459 * clear those fields for grids/monsters containing objects,
460 * and we clear it once for every such object.
463 void wipe_o_list(void)
467 /* Delete the existing objects */
468 for (i = 1; i < o_max; i++)
470 object_type *o_ptr = &o_list[i];
472 /* Skip dead objects */
473 if (!o_ptr->k_idx) continue;
475 /* Mega-Hack -- preserve artifacts */
476 if (!character_dungeon || preserve_mode)
478 /* Hack -- Preserve unknown artifacts */
479 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
481 /* Mega-Hack -- Preserve the artifact */
482 a_info[o_ptr->name1].cur_num = 0;
487 if (o_ptr->held_m_idx)
492 m_ptr = &m_list[o_ptr->held_m_idx];
494 /* Hack -- see above */
495 m_ptr->hold_o_idx = 0;
503 /* Access location */
510 /* Hack -- see above */
514 /* Wipe the object */
527 * @brief グローバルオブジェクト配列から空きを取得する /
528 * Acquires and returns the index of a "free" object.
529 * @return 開いているオブジェクト要素のID
531 * This routine should almost never fail, but in case it does,
532 * we must be sure to handle "failure" of this routine.
539 /* Initial allocation */
540 if (o_max < max_o_idx)
545 /* Expand object array */
551 /* Use this object */
556 /* Recycle dead objects */
557 for (i = 1; i < o_max; i++)
564 /* Skip live objects */
565 if (o_ptr->k_idx) continue;
570 /* Use this object */
575 /* Warn the player (except during dungeon creation) */
576 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
584 * @brief オブジェクト生成テーブルに生成制約を加える /
585 * Apply a "object restriction function" to the "object allocation table"
587 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
589 static errr get_obj_num_prep(void)
594 alloc_entry *table = alloc_kind_table;
596 /* Scan the allocation table */
597 for (i = 0; i < alloc_kind_size; i++)
599 /* Accept objects which pass the restriction, if any */
600 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
602 /* Accept this object */
603 table[i].prob2 = table[i].prob1;
606 /* Do not use this object */
609 /* Decline this object */
620 * @brief オブジェクト生成テーブルからアイテムを取得する /
621 * Choose an object kind that seems "appropriate" to the given level
623 * @return 選ばれたオブジェクトベースID
625 * This function uses the "prob2" field of the "object allocation table",\n
626 * and various local information, to calculate the "prob3" field of the\n
627 * same table, which is then used to choose an "appropriate" object, in\n
628 * a relatively efficient manner.\n
630 * It is (slightly) more likely to acquire an object of the given level\n
631 * than one of a lower level. This is done by choosing several objects\n
632 * appropriate to the given level and keeping the "hardest" one.\n
634 * Note that if no objects are "appropriate", then this function will\n
635 * fail, and return zero, but this should *almost* never happen.\n
637 s16b get_obj_num(int level)
643 alloc_entry *table = alloc_kind_table;
645 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
648 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
650 /* Occasional "boost" */
651 if (one_in_(GREAT_OBJ))
653 /* What a bizarre calculation */
654 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
661 /* Process probabilities */
662 for (i = 0; i < alloc_kind_size; i++)
664 /* Objects are sorted by depth */
665 if (table[i].level > level) break;
670 /* Access the index */
671 k_idx = table[i].index;
673 /* Access the actual kind */
674 k_ptr = &k_info[k_idx];
676 /* Hack -- prevent embedded chests */
677 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
680 table[i].prob3 = table[i].prob2;
683 total += table[i].prob3;
686 /* No legal objects */
687 if (total <= 0) return (0);
691 value = randint0(total);
693 /* Find the object */
694 for (i = 0; i < alloc_kind_size; i++)
696 /* Found the entry */
697 if (value < table[i].prob3) break;
700 value = value - table[i].prob3;
707 /* Try for a "better" object once (50%) or twice (10%) */
714 value = randint0(total);
716 /* Find the object */
717 for (i = 0; i < alloc_kind_size; i++)
719 /* Found the entry */
720 if (value < table[i].prob3) break;
723 value = value - table[i].prob3;
726 /* Keep the "best" one */
727 if (table[i].level < table[j].level) i = j;
730 /* Try for a "better" object twice (10%) */
737 value = randint0(total);
739 /* Find the object */
740 for (i = 0; i < alloc_kind_size; i++)
742 /* Found the entry */
743 if (value < table[i].prob3) break;
746 value = value - table[i].prob3;
749 /* Keep the "best" one */
750 if (table[i].level < table[j].level) i = j;
755 return (table[i].index);
760 * @brief オブジェクトを鑑定済にする /
761 * Known is true when the "attributes" of an object are "known".
762 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
764 * These include tohit, todam, toac, cost, and pval (charges).\n
766 * Note that "knowing" an object gives you everything that an "awareness"\n
767 * gives you, and much more. In fact, the player is always "aware" of any\n
768 * item of which he has full "knowledge".\n
770 * But having full knowledge of, say, one "wand of wonder", does not, by\n
771 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
772 * It happens that most "identify" routines (including "buying from a shop")\n
773 * will make the player "aware" of the object as well as fully "know" it.\n
775 * This routine also removes any inscriptions generated by "feelings".\n
777 void object_known(object_type *o_ptr)
779 /* Remove "default inscriptions" */
780 o_ptr->feeling = FEEL_NONE;
782 /* Clear the "Felt" info */
783 o_ptr->ident &= ~(IDENT_SENSE);
785 /* Clear the "Empty" info */
786 o_ptr->ident &= ~(IDENT_EMPTY);
788 /* Now we know about the item */
789 o_ptr->ident |= (IDENT_KNOWN);
793 * @brief オブジェクトを*鑑定*済にする /
794 * The player is now aware of the effects of the given object.
795 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
798 void object_aware(object_type *o_ptr)
800 bool mihanmei = !object_is_aware(o_ptr);
802 /* Fully aware of the effects */
803 k_info[o_ptr->k_idx].aware = TRUE;
805 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
806 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
810 char o_name[MAX_NLEN];
813 object_copy(q_ptr, o_ptr);
816 object_desc(o_name, q_ptr, OD_NAME_ONLY);
818 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
824 * @brief オブジェクトを試行済にする /
825 * Something has been "sampled"
826 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
829 void object_tried(object_type *o_ptr)
831 /* Mark it as tried (even if "aware") */
832 k_info[o_ptr->k_idx].tried = TRUE;
837 * @brief 未鑑定なベースアイテムの基本価格を返す /
838 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
839 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
840 * @return オブジェクトの未鑑定価格
842 static s32b object_value_base(object_type *o_ptr)
844 /* Aware item -- use template cost */
845 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
847 /* Analyze the type */
852 case TV_FOOD: return (5L);
854 /* Un-aware Potions */
855 case TV_POTION: return (20L);
857 /* Un-aware Scrolls */
858 case TV_SCROLL: return (20L);
860 /* Un-aware Staffs */
861 case TV_STAFF: return (70L);
864 case TV_WAND: return (50L);
867 case TV_ROD: return (90L);
870 case TV_RING: return (45L);
872 /* Un-aware Amulets */
873 case TV_AMULET: return (45L);
875 /* Figurines, relative to monster level */
878 int level = r_info[o_ptr->pval].level;
879 if (level < 20) return level*50L;
880 else if (level < 30) return 1000+(level-20)*150L;
881 else if (level < 40) return 2500+(level-30)*350L;
882 else if (level < 50) return 6000+(level-40)*800L;
883 else return 14000+(level-50)*2000L;
887 if (!o_ptr->pval) return 1000L;
888 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
891 /* Paranoia -- Oops */
897 * @brief オブジェクトのフラグ類から価格を算出する /
898 * Return the value of the flags the object has...
899 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
900 * @param plusses フラグに与える価格の基本重み
901 * @return オブジェクトのフラグ価格
903 s32b flag_cost(object_type *o_ptr, int plusses)
906 u32b flgs[TR_FLAG_SIZE];
910 object_kind *k_ptr = &k_info[o_ptr->k_idx];
912 object_flags(o_ptr, flgs);
915 * Exclude fixed flags of the base item.
916 * pval bonuses of base item will be treated later.
918 for (i = 0; i < TR_FLAG_SIZE; i++)
919 flgs[i] &= ~(k_ptr->flags[i]);
921 /* Exclude fixed flags of the fixed artifact. */
922 if (object_is_fixed_artifact(o_ptr))
924 artifact_type *a_ptr = &a_info[o_ptr->name1];
926 for (i = 0; i < TR_FLAG_SIZE; i++)
927 flgs[i] &= ~(a_ptr->flags[i]);
930 /* Exclude fixed flags of the ego-item. */
931 else if (object_is_ego(o_ptr))
933 ego_item_type *e_ptr = &e_info[o_ptr->name2];
935 for (i = 0; i < TR_FLAG_SIZE; i++)
936 flgs[i] &= ~(e_ptr->flags[i]);
941 * Calucurate values of remaining flags
943 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
944 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
945 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
946 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
947 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
948 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
949 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
950 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
951 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
952 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
953 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
954 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
955 total += (10000 + (2500 * plusses));
956 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
957 total += (10000 + (2500 * plusses));
961 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
962 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
963 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
964 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
965 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
966 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
967 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
968 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
969 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
970 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
971 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
972 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
973 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
974 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
975 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
976 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
977 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
978 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
979 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
980 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
981 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
983 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
984 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
985 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
986 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
987 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
988 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
989 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
990 total += (tmp_cost * count);
992 if (have_flag(flgs, TR_SUST_STR)) total += 850;
993 if (have_flag(flgs, TR_SUST_INT)) total += 850;
994 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
995 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
996 if (have_flag(flgs, TR_SUST_CON)) total += 850;
997 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
998 if (have_flag(flgs, TR_RIDING)) total += 0;
999 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1000 if (have_flag(flgs, TR_THROW)) total += 5000;
1001 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1002 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1006 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1007 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1008 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1009 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1010 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1011 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1012 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1013 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1014 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1015 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1016 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1017 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1018 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1019 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1020 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1021 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1022 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1023 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1024 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1025 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1026 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1027 total += (tmp_cost * count);
1029 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1030 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1031 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1032 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1033 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1034 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1035 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1036 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1037 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1038 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1039 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1040 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1041 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1042 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1043 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1044 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1045 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1046 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1047 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1048 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1049 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1050 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1051 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1052 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1053 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1054 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1055 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1056 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1057 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1058 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1059 if (have_flag(flgs, TR_REGEN)) total += 2500;
1060 if (have_flag(flgs, TR_WARNING)) total += 2000;
1061 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1062 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1063 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1064 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1065 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1066 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1067 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1068 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1069 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1070 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1071 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1072 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1073 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1074 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1075 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1076 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1077 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1078 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1079 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1080 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1081 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1082 if (have_flag(flgs, TR_TELEPORT))
1084 if (object_is_cursed(o_ptr))
1089 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1090 if (have_flag(flgs, TR_BLESSED)) total += 750;
1091 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1092 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1093 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1094 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1095 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1097 /* Also, give some extra for activatable powers... */
1098 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1100 const activation_type* const act_ptr = find_activation_info(o_ptr);
1102 total += act_ptr->value;
1111 * @brief オブジェクトの真の価格を算出する /
1112 * Return the value of the flags the object has...
1113 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1114 * @return オブジェクトの本価格
1116 * Return the "real" price of a "known" item, not including discounts\n
1118 * Wand and staffs get cost for each charge\n
1120 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1122 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1124 * Missiles are only worth 5 gold per bonus point, since they\n
1125 * usually appear in groups of 20, and we want the player to get\n
1126 * the same amount of cash for any "equivalent" item. Note that\n
1127 * missiles never have any of the "pval" flags, and in fact, they\n
1128 * only have a few of the available flags, primarily of the "slay"\n
1129 * and "brand" and "ignore" variety.\n
1131 * Armor with a negative armor bonus is worthless.\n
1132 * Weapons with negative hit+damage bonuses are worthless.\n
1134 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1136 s32b object_value_real(object_type *o_ptr)
1140 u32b flgs[TR_FLAG_SIZE];
1142 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1145 /* Hack -- "worthless" items */
1146 if (!k_info[o_ptr->k_idx].cost) return (0L);
1149 value = k_info[o_ptr->k_idx].cost;
1151 /* Extract some flags */
1152 object_flags(o_ptr, flgs);
1155 if (object_is_fixed_artifact(o_ptr))
1157 artifact_type *a_ptr = &a_info[o_ptr->name1];
1159 /* Hack -- "worthless" artifacts */
1160 if (!a_ptr->cost) return (0L);
1162 /* Hack -- Use the artifact cost instead */
1163 value = a_ptr->cost;
1164 value += flag_cost(o_ptr, o_ptr->pval);
1166 /* Don't add pval bonuses etc. */
1171 else if (object_is_ego(o_ptr))
1173 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1175 /* Hack -- "worthless" ego-items */
1176 if (!e_ptr->cost) return (0L);
1178 /* Hack -- Reward the ego-item with a bonus */
1179 value += e_ptr->cost;
1180 value += flag_cost(o_ptr, o_ptr->pval);
1188 for (i = 0; i < TR_FLAG_SIZE; i++)
1189 if (o_ptr->art_flags[i]) flag = TRUE;
1191 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1194 /* Analyze pval bonus for normal object */
1195 switch (o_ptr->tval)
1218 if (!o_ptr->pval) break;
1220 /* Hack -- Negative "pval" is always bad */
1221 if (o_ptr->pval < 0) return (0L);
1223 /* Give credit for stat bonuses */
1224 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1225 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1226 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1227 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1228 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1229 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1231 /* Give credit for stealth and searching */
1232 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1233 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1234 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1236 /* Give credit for infra-vision and tunneling */
1237 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1238 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1240 /* Give credit for extra attacks */
1241 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1243 /* Give credit for speed bonus */
1244 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1250 /* Analyze the item */
1251 switch (o_ptr->tval)
1256 /* Pay extra for charges, depending on standard number of
1257 * charges. Handle new-style wands correctly. -LM-
1259 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1266 /* Pay extra for charges, depending on standard number of
1269 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1279 /* Hack -- negative bonuses are bad */
1280 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1282 /* Give credit for bonuses */
1283 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1300 /* Hack -- negative armor bonus */
1301 if (o_ptr->to_a < 0) return (0L);
1303 /* Give credit for bonuses */
1304 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1317 /* Hack -- negative hit/damage bonuses */
1318 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1320 /* Factor in the bonuses */
1321 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1323 /* Hack -- Factor in extra damage dice and sides */
1324 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1325 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1336 /* Hack -- negative hit/damage bonuses */
1337 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1339 /* Factor in the bonuses */
1340 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1342 /* Hack -- Factor in extra damage dice and sides */
1343 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1344 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1350 /* Figurines, relative to monster level */
1353 int level = r_info[o_ptr->pval].level;
1354 if (level < 20) value = level*50L;
1355 else if (level < 30) value = 1000+(level-20)*150L;
1356 else if (level < 40) value = 2500+(level-30)*350L;
1357 else if (level < 50) value = 6000+(level-40)*800L;
1358 else value = 14000+(level-50)*2000L;
1364 if (!o_ptr->pval) value = 1000L;
1365 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1371 if (!o_ptr->pval) value = 0L;
1376 /* Worthless object */
1377 if (value < 0) return 0L;
1379 /* Return the value */
1385 * @brief オブジェクト価格算出のメインルーチン /
1386 * Return the price of an item including plusses (and charges)
1387 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1388 * @return オブジェクトの判明している現価格
1390 * This function returns the "value" of the given item (qty one)\n
1392 * Never notice "unknown" bonuses or properties, including "curses",\n
1393 * since that would give the player information he did not have.\n
1395 * Note that discounted items stay discounted forever, even if\n
1396 * the discount is "forgotten" by the player via memory loss.\n
1398 s32b object_value(object_type *o_ptr)
1403 /* Unknown items -- acquire a base value */
1404 if (object_is_known(o_ptr))
1406 /* Broken items -- worthless */
1407 if (object_is_broken(o_ptr)) return (0L);
1409 /* Cursed items -- worthless */
1410 if (object_is_cursed(o_ptr)) return (0L);
1412 /* Real value (see above) */
1413 value = object_value_real(o_ptr);
1416 /* Known items -- acquire the actual value */
1419 /* Hack -- Felt broken items */
1420 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1422 /* Hack -- Felt cursed items */
1423 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1425 /* Base value (see above) */
1426 value = object_value_base(o_ptr);
1430 /* Apply discount (if any) */
1431 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1434 /* Return the final value */
1441 * @brief 破壊可能なアイテムかを返す /
1442 * Determines whether an object can be destroyed, and makes fake inscription.
1443 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1444 * @return オブジェクトが破壊可能ならばTRUEを返す
1446 bool can_player_destroy_object(object_type *o_ptr)
1448 /* Artifacts cannot be destroyed */
1449 if (!object_is_artifact(o_ptr)) return TRUE;
1451 /* If object is unidentified, makes fake inscription */
1452 if (!object_is_known(o_ptr))
1454 byte feel = FEEL_SPECIAL;
1456 /* Hack -- Handle icky artifacts */
1457 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1459 /* Hack -- inscribe the artifact */
1460 o_ptr->feeling = feel;
1462 /* We have "felt" it (again) */
1463 o_ptr->ident |= (IDENT_SENSE);
1465 /* Combine the pack */
1466 p_ptr->notice |= (PN_COMBINE);
1469 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1475 /* Identified artifact -- Nothing to do */
1481 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1482 * Distribute charges of rods or wands.
1483 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1484 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1485 * @param amt 分割したい回数量 number of items that are transfered
1488 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1489 * charges need to be allocated between the two stacks. If all the items\n
1490 * are being dropped, it makes for a neater message to leave the original\n
1491 * stack's pval alone. -LM-\n
1493 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1495 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1497 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1498 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1500 /* Hack -- Rods also need to have their timeouts distributed. The
1501 * dropped stack will accept all time remaining to charge up to its
1504 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1506 if (q_ptr->pval > o_ptr->timeout)
1507 q_ptr->timeout = o_ptr->timeout;
1509 q_ptr->timeout = q_ptr->pval;
1511 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1517 * @brief 魔法棒やロッドの使用回数を減らす /
1518 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1519 * @param amt 減らしたい回数量 number of items that are transfered
1522 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1523 * charges of the stack needs to be reduced, unless all the items are\n
1524 * being destroyed. -LM-\n
1526 void reduce_charges(object_type *o_ptr, int amt)
1528 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1529 (amt < o_ptr->number))
1531 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1536 * Determine if an item can "absorb" a second item
1538 * See "object_absorb()" for the actual "absorption" code.
1540 * If permitted, we allow staffs (if they are known to have equal charges
1541 * and both are either known or confirmed empty) and wands (if both are
1542 * either known or confirmed empty) and rods (in all cases) to combine.
1543 * Staffs will unstack (if necessary) when they are used, but wands and
1544 * rods will only unstack if one is dropped. -LM-
1546 * If permitted, we allow weapons/armor to stack, if fully "known".
1548 * Missiles will combine if both stacks have the same "known" status.
1549 * This is done to make unidentified stacks of missiles useful.
1551 * Food, potions, scrolls, and "easy know" items always stack.
1553 * Chests, and activatable items, never stack (for various reasons).
1557 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1559 #define MAX_STACK_SIZE 99
1563 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1564 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1565 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1566 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1567 * @return 重ね合わせ可能なアイテム数
1569 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1573 /* Default maximum number of stack */
1574 int max_num = MAX_STACK_SIZE;
1576 /* Require identical object types */
1577 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1580 /* Analyze the items */
1581 switch (o_ptr->tval)
1583 /* Chests and Statues*/
1594 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1595 if (o_ptr->pval != j_ptr->pval) return 0;
1599 /* Figurines and Corpses*/
1604 if (o_ptr->pval != j_ptr->pval) return 0;
1610 /* Food and Potions and Scrolls */
1622 /* Require either knowledge or known empty for both staffs. */
1623 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1624 !object_is_known(o_ptr)) ||
1625 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1626 !object_is_known(j_ptr))) return 0;
1628 /* Require identical charges, since staffs are bulky. */
1629 if (o_ptr->pval != j_ptr->pval) return 0;
1638 /* Require either knowledge or known empty for both wands. */
1639 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1640 !object_is_known(o_ptr)) ||
1641 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1642 !object_is_known(j_ptr))) return 0;
1644 /* Wand charges combine in O&ZAngband. */
1650 /* Staffs and Wands and Rods */
1653 /* Prevent overflaw of timeout */
1654 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1660 /* Weapons and Armor */
1676 /* Rings, Amulets, Lites */
1682 /* Require full knowledge of both items */
1683 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1693 /* Require identical knowledge of both items */
1694 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1695 if (o_ptr->feeling != j_ptr->feeling) return 0;
1697 /* Require identical "bonuses" */
1698 if (o_ptr->to_h != j_ptr->to_h) return 0;
1699 if (o_ptr->to_d != j_ptr->to_d) return 0;
1700 if (o_ptr->to_a != j_ptr->to_a) return 0;
1702 /* Require identical "pval" code */
1703 if (o_ptr->pval != j_ptr->pval) return 0;
1705 /* Artifacts never stack */
1706 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1708 /* Require identical "ego-item" names */
1709 if (o_ptr->name2 != j_ptr->name2) return 0;
1711 /* Require identical added essence */
1712 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1713 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1715 /* Hack -- Never stack "powerful" items */
1716 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1718 /* Hack -- Never stack recharging items */
1719 if (o_ptr->timeout || j_ptr->timeout) return 0;
1721 /* Require identical "values" */
1722 if (o_ptr->ac != j_ptr->ac) return 0;
1723 if (o_ptr->dd != j_ptr->dd) return 0;
1724 if (o_ptr->ds != j_ptr->ds) return 0;
1733 /* Require knowledge */
1734 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1742 /* Hack -- Identical art_flags! */
1743 for (i = 0; i < TR_FLAG_SIZE; i++)
1744 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1746 /* Hack -- Require identical "cursed" status */
1747 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1749 /* Hack -- Require identical "broken" status */
1750 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1753 /* Hack -- require semi-matching "inscriptions" */
1754 if (o_ptr->inscription && j_ptr->inscription &&
1755 (o_ptr->inscription != j_ptr->inscription))
1758 /* Hack -- normally require matching "inscriptions" */
1759 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1761 /* Hack -- normally require matching "discounts" */
1762 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1765 /* They match, so they must be similar */
1770 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1771 * Determine if an item can absorb a second item.
1772 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1773 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1774 * @return 重ね合わせ可能ならばTRUEを返す。
1776 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1778 int total = o_ptr->number + j_ptr->number;
1781 /* Are these objects similar? */
1782 max_num = object_similar_part(o_ptr, j_ptr);
1784 /* Return if not similar */
1785 if (!max_num) return FALSE;
1787 /* Maximal "stacking" limit */
1788 if (total > max_num) return (0);
1791 /* They match, so they must be similar */
1797 * @brief 両オブジェクトをスロットに重ね合わせる。
1798 * Allow one item to "absorb" another, assuming they are similar
1799 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1800 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1803 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1805 int max_num = object_similar_part(o_ptr, j_ptr);
1806 int total = o_ptr->number + j_ptr->number;
1807 int diff = (total > max_num) ? total - max_num : 0;
1809 /* Combine quantity, lose excess items */
1810 o_ptr->number = (total > max_num) ? max_num : total;
1812 /* Hack -- blend "known" status */
1813 if (object_is_known(j_ptr)) object_known(o_ptr);
1815 /* Hack -- clear "storebought" if only one has it */
1816 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1817 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1819 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1820 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1823 /* Hack -- blend "mental" status */
1824 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1826 /* Hack -- blend "inscriptions" */
1827 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1829 /* Hack -- blend "feelings" */
1830 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1832 /* Hack -- could average discounts XXX XXX XXX */
1833 /* Hack -- save largest discount XXX XXX XXX */
1834 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1836 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1837 if (o_ptr->tval == TV_ROD)
1839 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1840 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1843 /* Hack -- if wands are stacking, combine the charges. -LM- */
1844 if (o_ptr->tval == TV_WAND)
1846 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1852 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1853 * Find the index of the object_kind with the given tval and sval
1854 * @param tval 検索したいベースアイテムのtval
1855 * @param sval 検索したいベースアイテムのsval
1858 IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
1865 for (k = 1; k < max_k_idx; k++)
1867 object_kind *k_ptr = &k_info[k];
1869 /* Require correct tval */
1870 if (k_ptr->tval != tval) continue;
1873 if (k_ptr->sval == sval) return (k);
1875 /* Ignore illegal items */
1876 if (sval != SV_ANY) continue;
1878 /* Apply the randomizer */
1879 if (!one_in_(++num)) continue;
1881 /* Use this value */
1885 /* Return this choice */
1893 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1903 * @brief オブジェクトを初期化する
1904 * Wipe an object clean.
1905 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1908 void object_wipe(object_type *o_ptr)
1910 /* Wipe the structure */
1911 (void)WIPE(o_ptr, object_type);
1916 * @brief オブジェクトを複製する
1917 * Wipe an object clean.
1918 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1919 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1922 void object_copy(object_type *o_ptr, object_type *j_ptr)
1924 /* Copy the structure */
1925 (void)COPY(o_ptr, j_ptr, object_type);
1930 * @brief オブジェクト構造体にベースアイテムを作成する
1931 * Prepare an object based on an object kind.
1932 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1933 * @param k_idx 新たに作成したいベースアイテム情報のID
1936 void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
1938 object_kind *k_ptr = &k_info[k_idx];
1940 /* Clear the record */
1943 /* Save the kind index */
1944 o_ptr->k_idx = k_idx;
1946 /* Efficiency -- tval/sval */
1947 o_ptr->tval = k_ptr->tval;
1948 o_ptr->sval = k_ptr->sval;
1950 /* Default "pval" */
1951 o_ptr->pval = k_ptr->pval;
1953 /* Default number */
1956 /* Default weight */
1957 o_ptr->weight = k_ptr->weight;
1960 o_ptr->to_h = k_ptr->to_h;
1961 o_ptr->to_d = k_ptr->to_d;
1962 o_ptr->to_a = k_ptr->to_a;
1965 o_ptr->ac = k_ptr->ac;
1966 o_ptr->dd = k_ptr->dd;
1967 o_ptr->ds = k_ptr->ds;
1969 /* Default activation */
1970 if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
1972 /* Hack -- worthless items are always "broken" */
1973 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1975 /* Hack -- cursed items are always "cursed" */
1976 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1977 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1978 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1979 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1980 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1981 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1986 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
1987 * Help determine an "enchantment bonus" for an object.
1988 * @param max ボーナス値の限度
1989 * @param level ボーナス値に加味する基準生成階
1990 * @return 算出されたボーナス値
1992 * To avoid floating point but still provide a smooth distribution of bonuses,\n
1993 * we simply round the results of division in such a way as to "average" the\n
1994 * correct floating point value.\n
1996 * This function has been changed. It uses "randnor()" to choose values from\n
1997 * a normal distribution, whose mean moves from zero towards the max as the\n
1998 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
1999 * and whose values are forced to lie between zero and the max, inclusive.\n
2001 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2002 * rare to get the "full" enchantment on an object, even a deep levels.\n
2004 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2006 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2008 * N 0 1 2 3 4 5 6 7 8 9 10\n
2009 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2010 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2011 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2012 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2013 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2014 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2015 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2016 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2017 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2018 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2019 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2020 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2021 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2022 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2023 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2024 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2025 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2026 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2028 s16b m_bonus(int max, int level)
2030 int bonus, stand, extra, value;
2033 /* Paranoia -- enforce maximal "level" */
2034 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2037 /* The "bonus" moves towards the max */
2038 bonus = ((max * level) / MAX_DEPTH);
2040 /* Hack -- determine fraction of error */
2041 extra = ((max * level) % MAX_DEPTH);
2043 /* Hack -- simulate floating point computations */
2044 if (randint0(MAX_DEPTH) < extra) bonus++;
2047 /* The "stand" is equal to one quarter of the max */
2050 /* Hack -- determine fraction of error */
2053 /* Hack -- simulate floating point computations */
2054 if (randint0(4) < extra) stand++;
2057 /* Choose an "interesting" value */
2058 value = randnor(bonus, stand);
2060 /* Enforce the minimum value */
2061 if (value < 0) return (0);
2063 /* Enforce the maximum value */
2064 if (value > max) return (max);
2072 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2073 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2076 static void object_mention(object_type *o_ptr)
2078 char o_name[MAX_NLEN];
2080 object_aware(o_ptr);
2081 object_known(o_ptr);
2083 /* Mark the item as fully known */
2084 o_ptr->ident |= (IDENT_MENTAL);
2087 object_desc(o_name, o_ptr, 0);
2088 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2092 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2093 * Mega-Hack -- Attempt to create one of the "Special Objects"
2094 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2095 * @return 生成に成功したらTRUEを返す。
2097 * We are only called from "make_object()", and we assume that\n
2098 * "apply_magic()" is called immediately after we return.\n
2100 * Note -- see "make_artifact()" and "apply_magic()"\n
2102 static bool make_artifact_special(object_type *o_ptr)
2107 /*! @note 地上ではキャンセルする / No artifacts in the town */
2108 if (!dun_level) return (FALSE);
2110 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2111 if (get_obj_num_hook) return (FALSE);
2113 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2114 for (i = 0; i < max_a_idx; i++)
2116 artifact_type *a_ptr = &a_info[i];
2118 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2119 if (!a_ptr->name) continue;
2121 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2122 if (a_ptr->cur_num) continue;
2123 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2124 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2126 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2127 * XXX XXX Enforce minimum "depth" (loosely) */
2128 if (a_ptr->level > object_level)
2130 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2131 int d = (a_ptr->level - object_level) * 2;
2132 if (!one_in_(d)) continue;
2135 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2136 if (!one_in_(a_ptr->rarity)) continue;
2138 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2139 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2140 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2141 if (k_info[k_idx].level > object_level)
2143 int d = (k_info[k_idx].level - object_level) * 5;
2144 if (!one_in_(d)) continue;
2147 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2148 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2149 object_prep(o_ptr, k_idx);
2152 random_artifact_resistance(o_ptr, a_ptr);
2156 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2162 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2163 * Mega-Hack -- Attempt to create one of the "Special Objects"
2164 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2165 * @return 生成に成功したらTRUEを返す。
2167 * Attempt to change an object into an artifact\n
2168 * This routine should only be called by "apply_magic()"\n
2169 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2171 static bool make_artifact(object_type *o_ptr)
2176 /* No artifacts in the town */
2177 if (!dun_level) return (FALSE);
2179 /* Paranoia -- no "plural" artifacts */
2180 if (o_ptr->number != 1) return (FALSE);
2182 /* Check the artifact list (skip the "specials") */
2183 for (i = 0; i < max_a_idx; i++)
2185 artifact_type *a_ptr = &a_info[i];
2187 /* Skip "empty" items */
2188 if (!a_ptr->name) continue;
2190 /* Cannot make an artifact twice */
2191 if (a_ptr->cur_num) continue;
2193 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2195 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2197 /* Must have the correct fields */
2198 if (a_ptr->tval != o_ptr->tval) continue;
2199 if (a_ptr->sval != o_ptr->sval) continue;
2201 /* XXX XXX Enforce minimum "depth" (loosely) */
2202 if (a_ptr->level > dun_level)
2204 /* Acquire the "out-of-depth factor" */
2205 int d = (a_ptr->level - dun_level) * 2;
2207 /* Roll for out-of-depth creation */
2208 if (!one_in_(d)) continue;
2211 /* We must make the "rarity roll" */
2212 if (!one_in_(a_ptr->rarity)) continue;
2214 /* Hack -- mark the item as an artifact */
2217 /* Hack: Some artifacts get random extra powers */
2218 random_artifact_resistance(o_ptr, a_ptr);
2230 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2231 * Choose random ego type
2232 * @param slot 取得したいエゴの装備部位
2233 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2234 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2236 static byte get_random_ego(byte slot, bool good)
2239 ego_item_type *e_ptr;
2243 for (i = 1; i < max_e_idx; i++)
2247 if (e_ptr->slot == slot
2248 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2251 total += (255 / e_ptr->rarity);
2255 value = randint1(total);
2257 for (i = 1; i < max_e_idx; i++)
2261 if (e_ptr->slot == slot
2262 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2265 value -= (255 / e_ptr->rarity);
2266 if (value <= 0L) break;
2274 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2275 * Apply magic to an item known to be a "weapon"
2276 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2277 * @param level 生成基準階
2278 * @param power 生成ランク
2281 * Hack -- note special base damage dice boosting\n
2282 * Hack -- note special processing for weapon/digger\n
2284 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2286 HIT_PROB tohit1 = randint1(5) + m_bonus(5, level);
2287 HIT_POINT todam1 = randint1(5) + m_bonus(5, level);
2289 HIT_PROB tohit2 = m_bonus(10, level);
2290 HIT_POINT todam2 = m_bonus(10, level);
2292 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2294 tohit2 = (tohit2+1)/2;
2295 todam2 = (todam2+1)/2;
2302 o_ptr->to_h += tohit1;
2303 o_ptr->to_d += todam1;
2309 o_ptr->to_h += tohit2;
2310 o_ptr->to_d += todam2;
2318 o_ptr->to_h -= tohit1;
2319 o_ptr->to_d -= todam1;
2324 /* Penalize again */
2325 o_ptr->to_h -= tohit2;
2326 o_ptr->to_d -= todam2;
2329 /* Cursed (if "bad") */
2330 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2333 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2336 switch (o_ptr->tval)
2343 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2344 create_artifact(o_ptr, FALSE);
2346 /* Special Ego-item */
2347 o_ptr->name2 = EGO_DIGGING;
2351 else if (power < -1)
2353 /* Hack -- Horrible digging bonus */
2354 o_ptr->pval = 0 - (5 + randint1(5));
2360 /* Hack -- Reverse digging bonus */
2361 o_ptr->pval = 0 - (o_ptr->pval);
2375 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2377 create_artifact(o_ptr, FALSE);
2382 /* Roll for an ego-item */
2383 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2384 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2386 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2388 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2393 switch (o_ptr->name2)
2396 if (one_in_(4) && (level > 40))
2397 add_flag(o_ptr->art_flags, TR_BLOWS);
2401 add_flag(o_ptr->art_flags, TR_RES_POIS);
2403 add_flag(o_ptr->art_flags, TR_WARNING);
2405 case EGO_KILL_DRAGON:
2407 add_flag(o_ptr->art_flags, TR_RES_POIS);
2411 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2413 case EGO_SLAYING_WEAPON:
2414 if (one_in_(3)) /* double damage */
2422 while (one_in_(o_ptr->dd));
2428 while (one_in_(o_ptr->ds));
2433 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2435 if (o_ptr->tval == TV_SWORD && one_in_(3))
2437 add_flag(o_ptr->art_flags, TR_VORPAL);
2442 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2448 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2450 add_flag(o_ptr->art_flags, TR_DEX);
2452 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2455 o_ptr->pval = m_bonus(5, level) + 1;
2457 case EGO_EARTHQUAKES:
2458 if (one_in_(3) && (level > 60))
2459 add_flag(o_ptr->art_flags, TR_BLOWS);
2461 o_ptr->pval = m_bonus(3, level);
2465 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2469 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2471 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2473 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2474 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2477 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2478 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2479 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2480 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2484 if (!o_ptr->art_name)
2486 /* Hack -- Super-charge the damage dice */
2487 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2489 /* Hack -- Lower the damage dice */
2490 if (o_ptr->dd > 9) o_ptr->dd = 9;
2495 else if (power < -1)
2497 /* Roll for ego-item */
2498 if (randint0(MAX_DEPTH) < level)
2502 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2503 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2509 switch (o_ptr->name2)
2512 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2513 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2515 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2516 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2517 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2518 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2519 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2520 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2534 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2536 create_artifact(o_ptr, FALSE);
2539 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2553 if (power > 2) /* power > 2 is debug only */
2555 create_artifact(o_ptr, FALSE);
2559 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2561 switch (o_ptr->name2)
2563 case EGO_SLAYING_BOLT:
2568 /* Hack -- super-charge the damage dice */
2569 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2571 /* Hack -- restrict the damage dice */
2572 if (o_ptr->dd > 9) o_ptr->dd = 9;
2576 else if (power < -1)
2578 /* Roll for ego-item */
2579 if (randint0(MAX_DEPTH) < level)
2581 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2591 * @brief ドラゴン装備にランダムな耐性を与える
2592 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2595 static void dragon_resist(object_type * o_ptr)
2600 one_dragon_ele_resistance(o_ptr);
2602 one_high_resistance(o_ptr);
2608 * @brief オブジェクトにランダムな強いESPを与える
2609 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2612 static bool add_esp_strong(object_type *o_ptr)
2614 bool nonliv = FALSE;
2616 switch (randint1(3))
2618 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2619 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2620 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2627 * @brief オブジェクトにランダムな弱いESPを与える
2628 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2629 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2632 static void add_esp_weak(object_type *o_ptr, bool extra)
2635 u32b weak_esp_list[] = {
2647 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2648 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2650 /* Add unduplicated weak esp flags randomly */
2651 for (i = 0; i < add_count; ++ i)
2653 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2655 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2656 weak_esp_list[choice] = weak_esp_list[i];
2662 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2663 * Apply magic to an item known to be "armor"
2664 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2665 * @param level 生成基準階
2666 * @param power 生成ランク
2669 * Hack -- note special processing for crown/helm\n
2670 * Hack -- note special processing for robe of permanence\n
2672 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2674 ARMOUR_CLASS toac1 = randint1(5) + m_bonus(5, level);
2675 ARMOUR_CLASS toac2 = m_bonus(10, level);
2681 o_ptr->to_a += toac1;
2687 o_ptr->to_a += toac2;
2695 o_ptr->to_a -= toac1;
2700 /* Penalize again */
2701 o_ptr->to_a -= toac2;
2704 /* Cursed (if "bad") */
2705 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2710 switch (o_ptr->tval)
2714 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2715 create_artifact(o_ptr, FALSE);
2725 /* Hack -- Try for "Robes of the Magi" */
2726 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2727 (o_ptr->sval == SV_ROBE) &&
2728 (randint0(100) < 15))
2732 o_ptr->name2 = EGO_YOIYAMI;
2733 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2734 o_ptr->sval = SV_YOIYAMI_ROBE;
2740 o_ptr->name2 = EGO_PERMANENCE;
2745 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2747 create_artifact(o_ptr, FALSE);
2753 bool okay_flag = TRUE;
2755 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2757 switch (o_ptr->name2)
2760 if (o_ptr->tval != TV_HARD_ARMOR)
2766 if (o_ptr->tval != TV_SOFT_ARMOR)
2775 if (okay_flag) break;
2777 switch (o_ptr->name2)
2779 case EGO_RESISTANCE:
2781 add_flag(o_ptr->art_flags, TR_RES_POIS);
2784 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2785 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2789 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2791 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2793 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2794 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2796 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2797 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2798 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2799 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2800 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2801 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2802 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2803 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2806 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2807 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2808 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2809 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2810 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2811 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2824 if (o_ptr->sval == SV_DRAGON_SHIELD)
2826 dragon_resist(o_ptr);
2827 if (!one_in_(3)) break;
2833 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2835 create_artifact(o_ptr, FALSE);
2841 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2842 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2843 && o_ptr->name2 == EGO_S_DWARVEN)
2850 switch (o_ptr->name2)
2853 if (!one_in_(3)) one_high_resistance(o_ptr);
2854 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2856 case EGO_REFLECTION:
2857 if (o_ptr->sval == SV_MIRROR_SHIELD)
2862 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2863 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2872 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2874 dragon_resist(o_ptr);
2875 if (!one_in_(3)) break;
2879 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2881 create_artifact(o_ptr, FALSE);
2884 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2888 else if (power < -1)
2890 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2898 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2900 dragon_resist(o_ptr);
2901 if (!one_in_(3)) break;
2906 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2908 create_artifact(o_ptr, FALSE);
2911 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2913 switch (o_ptr->name2)
2915 case EGO_SLOW_DESCENT:
2918 one_high_resistance(o_ptr);
2924 else if (power < -1)
2926 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2937 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2939 create_artifact(o_ptr, FALSE);
2944 bool ok_flag = TRUE;
2945 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2947 switch (o_ptr->name2)
2950 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2951 else add_esp_weak(o_ptr, FALSE);
2955 case EGO_REGENERATION:
2956 case EGO_LORDLINESS:
2962 if (one_in_(2)) add_esp_strong(o_ptr);
2963 else add_esp_weak(o_ptr, FALSE);
2966 default:/* not existing crown (wisdom,lite, etc...) */
2970 break; /* while (1) */
2976 else if (power < -1)
2980 bool ok_flag = TRUE;
2981 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
2983 switch (o_ptr->name2)
2985 case EGO_ANCIENT_CURSE:
2986 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2987 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2988 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2989 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2990 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2991 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2995 break; /* while (1) */
3004 if (o_ptr->sval == SV_DRAGON_HELM)
3006 dragon_resist(o_ptr);
3007 if (!one_in_(3)) break;
3013 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3015 create_artifact(o_ptr, FALSE);
3020 bool ok_flag = TRUE;
3021 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3023 switch (o_ptr->name2)
3025 case EGO_BRILLIANCE:
3027 case EGO_INFRAVISION:
3028 case EGO_H_PROTECTION:
3033 if (one_in_(2)) add_esp_strong(o_ptr);
3034 else add_esp_weak(o_ptr, FALSE);
3038 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3039 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3042 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3044 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3046 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3047 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3049 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3050 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3051 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3052 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3053 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3054 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3055 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3056 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3058 default:/* not existing helm (Magi, Might, etc...)*/
3062 break; /* while (1) */
3067 else if (power < -1)
3071 bool ok_flag = TRUE;
3072 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3074 switch (o_ptr->name2)
3076 case EGO_ANCIENT_CURSE:
3080 break; /* while (1) */
3091 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3093 create_artifact(o_ptr, FALSE);
3096 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3098 switch (o_ptr->name2)
3107 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3108 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3109 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3110 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3117 else if (power < -1)
3119 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3130 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3131 * Apply magic to an item known to be a "ring" or "amulet"
3132 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3133 * @param level 生成基準階
3134 * @param power 生成ランク
3137 * Hack -- note special "pval boost" code for ring of speed\n
3138 * Hack -- note that some items must be cursed (or blessed)\n
3140 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3142 /* Apply magic (good or bad) according to type */
3143 switch (o_ptr->tval)
3148 switch (o_ptr->sval)
3150 case SV_RING_ATTACKS:
3153 o_ptr->pval = m_bonus(2, level);
3154 if (one_in_(15)) o_ptr->pval++;
3155 if (o_ptr->pval < 1) o_ptr->pval = 1;
3161 o_ptr->ident |= (IDENT_BROKEN);
3164 o_ptr->curse_flags |= TRC_CURSED;
3167 o_ptr->pval = 0 - (o_ptr->pval);
3178 /* Strength, Constitution, Dexterity, Intelligence */
3184 o_ptr->pval = 1 + m_bonus(5, level);
3190 o_ptr->ident |= (IDENT_BROKEN);
3193 o_ptr->curse_flags |= TRC_CURSED;
3196 o_ptr->pval = 0 - (o_ptr->pval);
3202 /* Ring of Speed! */
3205 /* Base speed (1 to 10) */
3206 o_ptr->pval = randint1(5) + m_bonus(5, level);
3208 /* Super-charge the ring */
3209 while (randint0(100) < 50) o_ptr->pval++;
3215 o_ptr->ident |= (IDENT_BROKEN);
3218 o_ptr->curse_flags |= TRC_CURSED;
3221 o_ptr->pval = 0 - (o_ptr->pval);
3229 case SV_RING_LORDLY:
3233 one_lordly_high_resistance(o_ptr);
3237 /* Bonus to armor class */
3238 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3242 case SV_RING_WARNING:
3244 if (one_in_(3)) one_low_esp(o_ptr);
3249 case SV_RING_SEARCHING:
3251 /* Bonus to searching */
3252 o_ptr->pval = 1 + m_bonus(5, level);
3258 o_ptr->ident |= (IDENT_BROKEN);
3261 o_ptr->curse_flags |= TRC_CURSED;
3264 o_ptr->pval = 0 - (o_ptr->pval);
3270 /* Flames, Acid, Ice */
3271 case SV_RING_FLAMES:
3276 /* Bonus to armor class */
3277 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3281 /* Weakness, Stupidity */
3282 case SV_RING_WEAKNESS:
3283 case SV_RING_STUPIDITY:
3286 o_ptr->ident |= (IDENT_BROKEN);
3289 o_ptr->curse_flags |= TRC_CURSED;
3292 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3293 if (power > 0) power = 0 - power;
3298 /* WOE, Stupidity */
3302 o_ptr->ident |= (IDENT_BROKEN);
3305 o_ptr->curse_flags |= TRC_CURSED;
3308 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3309 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3310 if (power > 0) power = 0 - power;
3315 /* Ring of damage */
3316 case SV_RING_DAMAGE:
3318 /* Bonus to damage */
3319 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3325 o_ptr->ident |= (IDENT_BROKEN);
3328 o_ptr->curse_flags |= TRC_CURSED;
3331 o_ptr->to_d = 0 - o_ptr->to_d;
3337 /* Ring of Accuracy */
3338 case SV_RING_ACCURACY:
3341 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3347 o_ptr->ident |= (IDENT_BROKEN);
3350 o_ptr->curse_flags |= TRC_CURSED;
3353 o_ptr->to_h = 0 - o_ptr->to_h;
3359 /* Ring of Protection */
3360 case SV_RING_PROTECTION:
3362 /* Bonus to armor class */
3363 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3369 o_ptr->ident |= (IDENT_BROKEN);
3372 o_ptr->curse_flags |= TRC_CURSED;
3375 o_ptr->to_a = 0 - o_ptr->to_a;
3381 /* Ring of Slaying */
3382 case SV_RING_SLAYING:
3384 /* Bonus to damage and to hit */
3385 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3386 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3392 o_ptr->ident |= (IDENT_BROKEN);
3395 o_ptr->curse_flags |= TRC_CURSED;
3397 /* Reverse bonuses */
3398 o_ptr->to_h = 0 - o_ptr->to_h;
3399 o_ptr->to_d = 0 - o_ptr->to_d;
3405 case SV_RING_MUSCLE:
3407 o_ptr->pval = 1 + m_bonus(3, level);
3408 if (one_in_(4)) o_ptr->pval++;
3414 o_ptr->ident |= (IDENT_BROKEN);
3417 o_ptr->curse_flags |= TRC_CURSED;
3419 /* Reverse bonuses */
3420 o_ptr->pval = 0 - o_ptr->pval;
3425 case SV_RING_AGGRAVATION:
3428 o_ptr->ident |= (IDENT_BROKEN);
3431 o_ptr->curse_flags |= TRC_CURSED;
3433 if (power > 0) power = 0 - power;
3437 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3438 || (power > 2)) /* power > 2 is debug only */
3440 o_ptr->pval = MIN(o_ptr->pval, 4);
3441 /* Randart amulet */
3442 create_artifact(o_ptr, FALSE);
3444 else if ((power == 2) && one_in_(2))
3446 while(!o_ptr->name2)
3448 int tmp = m_bonus(10, level);
3449 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3450 switch(randint1(28))
3453 o_ptr->name2 = EGO_RING_THROW;
3456 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3457 o_ptr->name2 = EGO_RING_REGEN;
3460 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3461 o_ptr->name2 = EGO_RING_LITE;
3464 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3465 o_ptr->name2 = EGO_RING_TELEPORT;
3468 if (o_ptr->to_h) break;
3469 o_ptr->name2 = EGO_RING_TO_H;
3472 if (o_ptr->to_d) break;
3473 o_ptr->name2 = EGO_RING_TO_D;
3476 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3477 o_ptr->name2 = EGO_RING_SLAY;
3480 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3481 o_ptr->name2 = EGO_RING_WIZARD;
3484 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3485 o_ptr->name2 = EGO_RING_HERO;
3488 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3489 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3490 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3491 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3494 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3495 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;
3496 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3497 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3498 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3501 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3502 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;
3503 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3504 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3505 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3508 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3509 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;
3510 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3511 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3514 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3515 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;
3516 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3517 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3519 case 21: case 22: case 23: case 24: case 25: case 26:
3520 switch (o_ptr->sval)
3523 if (!one_in_(3)) break;
3524 o_ptr->name2 = EGO_RING_D_SPEED;
3526 case SV_RING_DAMAGE:
3527 case SV_RING_ACCURACY:
3528 case SV_RING_SLAYING:
3529 if (one_in_(2)) break;
3530 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3533 o_ptr->name2 = EGO_RING_BERSERKER;
3534 o_ptr->to_h -= 2+randint1(4);
3535 o_ptr->to_d += 2+randint1(4);
3538 case SV_RING_PROTECTION:
3539 o_ptr->name2 = EGO_RING_SUPER_AC;
3540 o_ptr->to_a += 7 + m_bonus(5, level);
3542 case SV_RING_RES_FEAR:
3543 o_ptr->name2 = EGO_RING_HERO;
3546 if (one_in_(2)) break;
3547 o_ptr->name2 = EGO_RING_HUNTER;
3549 case SV_RING_SEARCHING:
3550 o_ptr->name2 = EGO_RING_STEALTH;
3552 case SV_RING_TELEPORTATION:
3553 o_ptr->name2 = EGO_RING_TELE_AWAY;
3555 case SV_RING_RES_BLINDNESS:
3557 o_ptr->name2 = EGO_RING_RES_LITE;
3559 o_ptr->name2 = EGO_RING_RES_DARK;
3561 case SV_RING_LORDLY:
3562 if (!one_in_(20)) break;
3563 one_lordly_high_resistance(o_ptr);
3564 one_lordly_high_resistance(o_ptr);
3565 o_ptr->name2 = EGO_RING_TRUE;
3567 case SV_RING_SUSTAIN:
3568 if (!one_in_(4)) break;
3569 o_ptr->name2 = EGO_RING_RES_TIME;
3571 case SV_RING_FLAMES:
3572 if (!one_in_(2)) break;
3573 o_ptr->name2 = EGO_RING_DRAGON_F;
3576 if (!one_in_(2)) break;
3577 o_ptr->name2 = EGO_RING_DRAGON_C;
3579 case SV_RING_WARNING:
3580 if (!one_in_(2)) break;
3581 o_ptr->name2 = EGO_RING_M_DETECT;
3590 o_ptr->curse_flags = 0L;
3592 else if ((power == -2) && one_in_(2))
3594 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3595 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3596 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3597 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3598 o_ptr->art_flags[0] = 0;
3599 o_ptr->art_flags[1] = 0;
3600 while(!o_ptr->name2)
3602 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3606 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3607 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3610 o_ptr->name2 = EGO_RING_NO_MELEE;
3613 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3614 o_ptr->name2 = EGO_RING_AGGRAVATE;
3617 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3618 o_ptr->name2 = EGO_RING_TY_CURSE;
3621 o_ptr->name2 = EGO_RING_ALBINO;
3626 o_ptr->ident |= (IDENT_BROKEN);
3629 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3637 switch (o_ptr->sval)
3639 /* Amulet of wisdom/charisma */
3640 case SV_AMULET_INTELLIGENCE:
3641 case SV_AMULET_WISDOM:
3642 case SV_AMULET_CHARISMA:
3644 o_ptr->pval = 1 + m_bonus(5, level);
3650 o_ptr->ident |= (IDENT_BROKEN);
3653 o_ptr->curse_flags |= (TRC_CURSED);
3655 /* Reverse bonuses */
3656 o_ptr->pval = 0 - o_ptr->pval;
3662 /* Amulet of brilliance */
3663 case SV_AMULET_BRILLIANCE:
3665 o_ptr->pval = 1 + m_bonus(3, level);
3666 if (one_in_(4)) o_ptr->pval++;
3672 o_ptr->ident |= (IDENT_BROKEN);
3675 o_ptr->curse_flags |= (TRC_CURSED);
3677 /* Reverse bonuses */
3678 o_ptr->pval = 0 - o_ptr->pval;
3684 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3688 o_ptr->curse_flags |= (TRC_CURSED);
3693 case SV_AMULET_RESISTANCE:
3695 if (one_in_(5)) one_high_resistance(o_ptr);
3696 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3700 /* Amulet of searching */
3701 case SV_AMULET_SEARCHING:
3703 o_ptr->pval = randint1(2) + m_bonus(4, level);
3709 o_ptr->ident |= (IDENT_BROKEN);
3712 o_ptr->curse_flags |= (TRC_CURSED);
3714 /* Reverse bonuses */
3715 o_ptr->pval = 0 - (o_ptr->pval);
3721 /* Amulet of the Magi -- never cursed */
3722 case SV_AMULET_THE_MAGI:
3724 o_ptr->pval = randint1(5) + m_bonus(5, level);
3725 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3727 /* gain one low ESP */
3728 add_esp_weak(o_ptr, FALSE);
3733 /* Amulet of Doom -- always cursed */
3734 case SV_AMULET_DOOM:
3737 o_ptr->ident |= (IDENT_BROKEN);
3740 o_ptr->curse_flags |= (TRC_CURSED);
3743 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3744 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3745 if (power > 0) power = 0 - power;
3750 case SV_AMULET_MAGIC_MASTERY:
3752 o_ptr->pval = 1 + m_bonus(4, level);
3758 o_ptr->ident |= (IDENT_BROKEN);
3761 o_ptr->curse_flags |= (TRC_CURSED);
3763 /* Reverse bonuses */
3764 o_ptr->pval = 0 - o_ptr->pval;
3770 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3771 || (power > 2)) /* power > 2 is debug only */
3773 o_ptr->pval = MIN(o_ptr->pval, 4);
3774 /* Randart amulet */
3775 create_artifact(o_ptr, FALSE);
3777 else if ((power == 2) && one_in_(2))
3779 while(!o_ptr->name2)
3781 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3782 switch(randint1(21))
3785 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3786 o_ptr->name2 = EGO_AMU_SLOW_D;
3789 if (o_ptr->pval) break;
3790 o_ptr->name2 = EGO_AMU_INFRA;
3793 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3794 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3797 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3798 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3801 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3802 o_ptr->name2 = EGO_AMU_LEVITATION;
3804 case 10: case 11: case 21:
3805 o_ptr->name2 = EGO_AMU_AC;
3808 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3809 if (m_bonus(10, level) > 8)
3810 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3812 o_ptr->name2 = EGO_AMU_RES_FIRE;
3815 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3816 if (m_bonus(10, level) > 8)
3817 o_ptr->name2 = EGO_AMU_RES_COLD_;
3819 o_ptr->name2 = EGO_AMU_RES_COLD;
3822 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3823 if (m_bonus(10, level) > 8)
3824 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3826 o_ptr->name2 = EGO_AMU_RES_ELEC;
3829 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3830 if (m_bonus(10, level) > 8)
3831 o_ptr->name2 = EGO_AMU_RES_ACID_;
3833 o_ptr->name2 = EGO_AMU_RES_ACID;
3835 case 16: case 17: case 18: case 19: case 20:
3836 switch (o_ptr->sval)
3838 case SV_AMULET_TELEPORT:
3839 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3840 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3841 else o_ptr->name2 = EGO_AMU_TELEPORT;
3843 case SV_AMULET_RESIST_ACID:
3844 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3846 case SV_AMULET_SEARCHING:
3847 o_ptr->name2 = EGO_AMU_STEALTH;
3849 case SV_AMULET_BRILLIANCE:
3850 if (!one_in_(3)) break;
3851 o_ptr->name2 = EGO_AMU_IDENT;
3853 case SV_AMULET_CHARISMA:
3854 if (!one_in_(3)) break;
3855 o_ptr->name2 = EGO_AMU_CHARM;
3857 case SV_AMULET_THE_MAGI:
3858 if (one_in_(2)) break;
3859 o_ptr->name2 = EGO_AMU_GREAT;
3861 case SV_AMULET_RESISTANCE:
3862 if (!one_in_(5)) break;
3863 o_ptr->name2 = EGO_AMU_DEFENDER;
3865 case SV_AMULET_TELEPATHY:
3866 if (!one_in_(3)) break;
3867 o_ptr->name2 = EGO_AMU_DETECTION;
3873 o_ptr->curse_flags = 0L;
3875 else if ((power == -2) && one_in_(2))
3877 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3878 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3879 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3880 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3881 o_ptr->art_flags[0] = 0;
3882 o_ptr->art_flags[1] = 0;
3883 while(!o_ptr->name2)
3885 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3889 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3890 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3893 o_ptr->name2 = EGO_AMU_FOOL;
3896 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3897 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3900 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3901 o_ptr->name2 = EGO_AMU_TY_CURSE;
3904 o_ptr->name2 = EGO_AMU_NAIVETY;
3909 o_ptr->ident |= (IDENT_BROKEN);
3912 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3920 * @brief モンスターが人形のベースにできるかを返す
3921 * @param r_idx チェックしたいモンスター種族のID
3922 * @return 人形にできるならTRUEを返す
3924 static bool item_monster_okay(MONRACE_IDX r_idx)
3926 monster_race *r_ptr = &r_info[r_idx];
3929 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3930 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3931 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3932 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3933 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3934 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3942 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3943 * Apply magic to an item known to be "boring"
3944 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3945 * @param level 生成基準階
3946 * @param power 生成ランク
3949 * Hack -- note the special code for various items
3951 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3953 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3958 /* Apply magic (good or bad) according to type */
3959 switch (o_ptr->tval)
3968 o_ptr->ident |= (IDENT_BROKEN);
3971 o_ptr->curse_flags |= (TRC_CURSED);
3978 o_ptr->xtra4 = o_ptr->pval;
3984 /* Hack -- Torches -- random fuel */
3985 if (o_ptr->sval == SV_LITE_TORCH)
3987 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3991 /* Hack -- Lanterns -- random fuel */
3992 if (o_ptr->sval == SV_LITE_LANTERN)
3994 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
3998 if (power > 2) /* power > 2 is debug only */
4000 create_artifact(o_ptr, FALSE);
4002 else if ((power == 2) || ((power == 1) && one_in_(3)))
4004 while (!o_ptr->name2)
4008 bool okay_flag = TRUE;
4010 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4012 switch (o_ptr->name2)
4015 if (o_ptr->sval == SV_LITE_FEANOR)
4023 else if (power == -2)
4025 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4027 switch (o_ptr->name2)
4029 case EGO_LITE_DARKNESS:
4032 if (o_ptr->sval == SV_LITE_TORCH)
4034 add_flag(o_ptr->art_flags, TR_LITE_M1);
4036 else if (o_ptr->sval == SV_LITE_LANTERN)
4038 add_flag(o_ptr->art_flags, TR_LITE_M2);
4040 else if (o_ptr->sval == SV_LITE_FEANOR)
4042 add_flag(o_ptr->art_flags, TR_LITE_M3);
4054 /* The wand or staff gets a number of initial charges equal
4055 * to between 1/2 (+1) and the full object kind's pval. -LM-
4057 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4063 /* Transfer the pval. -LM- */
4064 o_ptr->pval = k_ptr->pval;
4071 object_aware(o_ptr);
4072 object_known(o_ptr);
4078 PARAMETER_VALUE i = 1;
4081 monster_race *r_ptr;
4083 /* Pick a random non-unique monster race */
4086 i = randint1(max_r_idx - 1);
4088 if (!item_monster_okay(i)) continue;
4089 if (i == MON_TSUCHINOKO) continue;
4093 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4095 /* Ignore dead monsters */
4096 if (!r_ptr->rarity) continue;
4098 /* Ignore uncommon monsters */
4099 if (r_ptr->rarity > 100) continue;
4101 /* Prefer less out-of-depth monsters */
4102 if (randint0(check)) continue;
4109 /* Some figurines are cursed */
4110 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4117 PARAMETER_VALUE i = 1;
4122 monster_race *r_ptr;
4124 if (o_ptr->sval == SV_SKELETON)
4126 match = RF9_DROP_SKELETON;
4128 else if (o_ptr->sval == SV_CORPSE)
4130 match = RF9_DROP_CORPSE;
4133 /* Hack -- Remove the monster restriction */
4134 get_mon_num_prep(item_monster_okay, NULL);
4136 /* Pick a random non-unique monster race */
4139 i = get_mon_num(dun_level);
4143 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4145 /* Ignore dead monsters */
4146 if (!r_ptr->rarity) continue;
4148 /* Ignore corpseless monsters */
4149 if (!(r_ptr->flags9 & match)) continue;
4151 /* Prefer less out-of-depth monsters */
4152 if (randint0(check)) continue;
4160 object_aware(o_ptr);
4161 object_known(o_ptr);
4167 PARAMETER_VALUE i = 1;
4169 monster_race *r_ptr;
4171 /* Pick a random monster race */
4174 i = randint1(max_r_idx - 1);
4178 /* Ignore dead monsters */
4179 if (!r_ptr->rarity) continue;
4188 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4190 object_aware(o_ptr);
4191 object_known(o_ptr);
4198 DEPTH obj_level = k_info[o_ptr->k_idx].level;
4200 /* Hack -- skip ruined chests */
4201 if (obj_level <= 0) break;
4203 /* Hack -- pick a "difficulty" */
4204 o_ptr->pval = randint1(obj_level);
4205 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4207 o_ptr->xtra3 = dun_level + 5;
4209 /* Never exceed "difficulty" of 55 to 59 */
4210 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4218 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4219 * Complete the "creation" of an object by applying "magic" to the item
4220 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4222 * @param mode 生成オプション
4225 * This includes not only rolling for random bonuses, but also putting the\n
4226 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4227 * staffs, giving fuel to lites, and placing traps on chests.\n
4229 * In particular, note that "Instant Artifacts", if "created" by an external\n
4230 * routine, must pass through this function to complete the actual creation.\n
4232 * The base "chance" of the item being "good" increases with the "level"\n
4233 * parameter, which is usually derived from the dungeon level, being equal\n
4234 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4235 * the object is guaranteed to be "good". If an object is "good", then\n
4236 * the chance that the object will be "great" (ego-item or artifact), also\n
4237 * increases with the "level", being equal to half the level, plus 5, up to\n
4238 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4239 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4241 * If the object is not "good", there is a chance it will be "cursed", and\n
4242 * if it is "cursed", there is a chance it will be "broken". These chances\n
4243 * are related to the "good" / "great" chances above.\n
4245 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4246 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4248 * If "okay" is true, and the object is going to be "great", then there is\n
4249 * a chance that an artifact will be created. This is true even if both the\n
4250 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4251 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4253 void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
4255 int i, rolls, f1, f2, power;
4257 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4259 /* Maximum "level" for various things */
4260 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4262 /* Base chance of being "good" */
4265 /* Maximal chance of being "good" */
4266 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4268 /* Base chance of being "great" */
4271 /* Maximal chance of being "great" */
4272 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4273 f2 = d_info[dungeon_type].obj_great;
4275 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4280 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4289 /* Roll for "good" */
4290 if ((mode & AM_GOOD) || magik(f1))
4295 /* Roll for "great" */
4296 if ((mode & AM_GREAT) || magik(f2))
4300 /* Roll for "special" */
4301 if (mode & AM_SPECIAL) power = 3;
4305 /* Roll for "cursed" */
4308 /* Assume "cursed" */
4311 /* Roll for "broken" */
4312 if (magik(f2)) power = -2;
4316 if (mode & AM_CURSED)
4318 /* Assume 'cursed' */
4323 /* Everything else gets more badly cursed */
4330 /* Assume no rolls */
4333 /* Get one roll if excellent */
4334 if (power >= 2) rolls = 1;
4336 /* Hack -- Get four rolls if forced great or special */
4337 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4339 /* Hack -- Get no rolls if not allowed */
4340 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4342 /* Roll for artifacts if allowed */
4343 for (i = 0; i < rolls; i++)
4345 /* Roll for an artifact */
4346 if (make_artifact(o_ptr)) break;
4347 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4349 if (make_artifact(o_ptr)) break;
4354 /* Hack -- analyze artifacts */
4355 if (object_is_fixed_artifact(o_ptr))
4357 artifact_type *a_ptr = &a_info[o_ptr->name1];
4359 /* Hack -- Mark the artifact as "created" */
4362 /* Hack -- Memorize location of artifact in saved floors */
4363 if (character_dungeon)
4364 a_ptr->floor_id = p_ptr->floor_id;
4366 /* Extract the other fields */
4367 o_ptr->pval = a_ptr->pval;
4368 o_ptr->ac = a_ptr->ac;
4369 o_ptr->dd = a_ptr->dd;
4370 o_ptr->ds = a_ptr->ds;
4371 o_ptr->to_a = a_ptr->to_a;
4372 o_ptr->to_h = a_ptr->to_h;
4373 o_ptr->to_d = a_ptr->to_d;
4374 o_ptr->weight = a_ptr->weight;
4375 o_ptr->xtra2 = a_ptr->act_idx;
4377 if (o_ptr->name1 == ART_MILIM)
4379 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4385 /* Hack -- extract the "broken" flag */
4386 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4388 /* Hack -- extract the "cursed" flag */
4389 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4390 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4391 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4392 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4393 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4394 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4402 switch (o_ptr->tval)
4411 if (power) a_m_aux_1(o_ptr, lev, power);
4417 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4423 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4437 /* Elven Cloak and Black Clothes ... */
4438 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4439 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4440 o_ptr->pval = randint1(4);
4444 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4445 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4446 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4447 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4448 a_m_aux_2(o_ptr, lev, power);
4450 if (power) a_m_aux_2(o_ptr, lev, power);
4458 if (!power && (randint0(100) < 50)) power = -1;
4459 a_m_aux_3(o_ptr, lev, power);
4465 a_m_aux_4(o_ptr, lev, power);
4470 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4471 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4472 (p_ptr->pseikaku == SEIKAKU_SEXY))
4475 add_flag(o_ptr->art_flags, TR_STR);
4476 add_flag(o_ptr->art_flags, TR_INT);
4477 add_flag(o_ptr->art_flags, TR_WIS);
4478 add_flag(o_ptr->art_flags, TR_DEX);
4479 add_flag(o_ptr->art_flags, TR_CON);
4480 add_flag(o_ptr->art_flags, TR_CHR);
4483 /* Hack -- analyze ego-items */
4484 if (object_is_ego(o_ptr))
4486 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4488 /* Hack -- acquire "broken" flag */
4489 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4491 /* Hack -- acquire "cursed" flag */
4492 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4493 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4494 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4495 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4496 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4497 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4499 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4500 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4501 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4502 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4503 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4504 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4505 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4506 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4512 while (one_in_(o_ptr->dd));
4514 if (o_ptr->dd > 9) o_ptr->dd = 9;
4517 /* Hack -- apply activatin index if needed */
4518 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4520 /* Hack -- apply extra penalties if needed */
4521 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4523 /* Hack -- obtain bonuses */
4524 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4525 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4526 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4528 /* Hack -- obtain pval */
4529 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4532 /* Hack -- apply extra bonuses if needed */
4535 /* Hack -- obtain bonuses */
4536 if (e_ptr->max_to_h)
4538 if (e_ptr->max_to_h > 127)
4539 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4540 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4542 if (e_ptr->max_to_d)
4544 if (e_ptr->max_to_d > 127)
4545 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4546 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4548 if (e_ptr->max_to_a)
4550 if (e_ptr->max_to_a > 127)
4551 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4552 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4555 /* Accuracy ego must have high to_h */
4556 if(o_ptr->name2 == EGO_ACCURACY)
4558 while(o_ptr->to_h < o_ptr->to_d + 10)
4563 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4566 /* Accuracy ego must have high to_h */
4567 if(o_ptr->name2 == EGO_VELOCITY)
4569 while(o_ptr->to_d < o_ptr->to_h + 10)
4574 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4577 /* Protection ego must have high to_a */
4578 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4580 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4583 /* Hack -- obtain pval */
4584 if (e_ptr->max_pval)
4586 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4589 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4591 else if (o_ptr->name2 == EGO_DEMON)
4593 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4595 o_ptr->pval += randint1(2);
4599 o_ptr->pval += randint1(e_ptr->max_pval);
4602 else if (o_ptr->name2 == EGO_ATTACKS)
4604 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4605 if (o_ptr->pval > 3) o_ptr->pval = 3;
4606 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4607 o_ptr->pval += randint1(2);
4609 else if (o_ptr->name2 == EGO_BAT)
4611 o_ptr->pval = randint1(e_ptr->max_pval);
4612 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4614 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4616 o_ptr->pval = randint1(e_ptr->max_pval);
4620 o_ptr->pval += randint1(e_ptr->max_pval);
4625 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4627 o_ptr->pval = randint1(o_ptr->pval);
4629 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4637 /* Examine real objects */
4640 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4642 /* Hack -- acquire "broken" flag */
4643 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4645 /* Hack -- acquire "cursed" flag */
4646 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4647 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4648 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4649 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4650 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4651 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4659 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4660 * Hack -- determine if a template is "good"
4661 * @param k_idx 判定したいベースアイテムのID
4662 * @return ベースアイテムが上質ならばTRUEを返す。
4664 static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4666 object_kind *k_ptr = &k_info[k_idx];
4668 /* Analyze the item type */
4669 switch (k_ptr->tval)
4671 /* Armor -- Good unless damaged */
4682 if (k_ptr->to_a < 0) return (FALSE);
4686 /* Weapons -- Good unless damaged */
4693 if (k_ptr->to_h < 0) return (FALSE);
4694 if (k_ptr->to_d < 0) return (FALSE);
4698 /* Ammo -- Arrows/Bolts are good */
4705 /* Books -- High level books are good (except Arcane books) */
4707 case TV_SORCERY_BOOK:
4708 case TV_NATURE_BOOK:
4713 case TV_DAEMON_BOOK:
4714 case TV_CRUSADE_BOOK:
4716 case TV_HISSATSU_BOOK:
4719 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4723 /* Rings -- Rings of Speed are good */
4726 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4727 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4731 /* Amulets -- Amulets of the Magi and Resistance are good */
4734 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4735 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4740 /* Assume not good */
4745 * @brief 生成階に応じたベースアイテムの生成を行う。
4746 * Attempt to make an object (normal or good/great)
4747 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4748 * @param mode オプションフラグ
4749 * @return 生成に成功したらTRUEを返す。
4751 * This routine plays nasty games to generate the "special artifacts".\n
4752 * This routine uses "object_level" for the "generation level".\n
4753 * We assume that the given object has been "wiped".\n
4755 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
4761 /* Chance of "special object" */
4762 prob = ((mode & AM_GOOD) ? 10 : 1000);
4764 /* Base level for the object */
4765 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4768 /* Generate a special object, or a normal object */
4769 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4774 if ((mode & AM_GOOD) && !get_obj_num_hook)
4776 /* Activate restriction (if already specified, use that) */
4777 get_obj_num_hook = kind_is_good;
4780 /* Restricted objects - prepare allocation table */
4781 if (get_obj_num_hook) get_obj_num_prep();
4783 /* Pick a random object */
4784 k_idx = get_obj_num(base);
4786 /* Restricted objects */
4787 if (get_obj_num_hook)
4789 /* Clear restriction */
4790 get_obj_num_hook = NULL;
4792 /* Reset allocation table to default */
4796 /* Handle failure */
4797 if (!k_idx) return (FALSE);
4799 /* Prepare the object */
4800 object_prep(j_ptr, k_idx);
4803 /* Apply magic (allow artifacts) */
4804 apply_magic(j_ptr, object_level, mode);
4806 /* Hack -- generate multiple spikes/missiles */
4807 switch (j_ptr->tval)
4815 j_ptr->number = (byte)damroll(6, 7);
4819 obj_level = k_info[j_ptr->k_idx].level;
4820 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4822 if (cheat_peek) object_mention(j_ptr);
4830 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4831 * Attempt to place an object (normal or good/great) at the given location.
4832 * @param y 配置したいフロアのY座標
4833 * @param x 配置したいフロアのX座標
4834 * @param mode オプションフラグ
4835 * @return 生成に成功したらTRUEを返す。
4837 * This routine plays nasty games to generate the "special artifacts".\n
4838 * This routine uses "object_level" for the "generation level".\n
4839 * This routine requires a clean floor grid destination.\n
4841 void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
4846 cave_type *c_ptr = &cave[y][x];
4852 /* Paranoia -- check bounds */
4853 if (!in_bounds(y, x)) return;
4855 /* Require floor space */
4856 if (!cave_drop_bold(y, x)) return;
4858 /* Avoid stacking on other objects */
4859 if (c_ptr->o_idx) return;
4862 /* Get local object */
4865 /* Wipe the object */
4868 /* Make an object (if possible) */
4869 if (!make_object(q_ptr, mode)) return;
4872 /* Make an object */
4880 /* Acquire object */
4881 o_ptr = &o_list[o_idx];
4883 /* Structure Copy */
4884 object_copy(o_ptr, q_ptr);
4891 o_ptr->next_o_idx = c_ptr->o_idx;
4893 /* Place the object */
4894 c_ptr->o_idx = o_idx;
4904 /* Hack -- Preserve artifacts */
4905 if (object_is_fixed_artifact(q_ptr))
4907 a_info[q_ptr->name1].cur_num = 0;
4914 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4915 * Make a treasure object
4916 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4917 * @return 生成に成功したらTRUEを返す。
4919 * The location must be a legal, clean, floor grid.
4921 bool make_gold(object_type *j_ptr)
4928 /* Hack -- Pick a Treasure variety */
4929 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4931 /* Apply "extra" magic */
4932 if (one_in_(GREAT_OBJ))
4934 i += randint1(object_level + 1);
4937 /* Hack -- Creeping Coins only generate "themselves" */
4938 if (coin_type) i = coin_type;
4940 /* Do not create "illegal" Treasure Types */
4941 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4943 /* Prepare a gold object */
4944 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4946 /* Hack -- Base coin cost */
4947 base = k_info[OBJ_GOLD_LIST+i].cost;
4949 /* Determine how much the treasure is "worth" */
4950 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4958 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
4959 * Places a treasure (Gold or Gems) at given location
4960 * @param y 配置したいフロアのY座標
4961 * @param x 配置したいフロアのX座標
4962 * @return 生成に成功したらTRUEを返す。
4964 * The location must be a legal, clean, floor grid.
4966 void place_gold(POSITION y, POSITION x)
4971 cave_type *c_ptr = &cave[y][x];
4978 /* Paranoia -- check bounds */
4979 if (!in_bounds(y, x)) return;
4981 /* Require floor space */
4982 if (!cave_drop_bold(y, x)) return;
4984 /* Avoid stacking on other objects */
4985 if (c_ptr->o_idx) return;
4988 /* Get local object */
4991 /* Wipe the object */
4994 /* Make some gold */
4995 if (!make_gold(q_ptr)) return;
4998 /* Make an object */
5006 /* Acquire object */
5007 o_ptr = &o_list[o_idx];
5009 /* Copy the object */
5010 object_copy(o_ptr, q_ptr);
5017 o_ptr->next_o_idx = c_ptr->o_idx;
5019 /* Place the object */
5020 c_ptr->o_idx = o_idx;
5032 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5033 * Let an object fall to the ground at or near a location.
5034 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5035 * @param chance ドロップの成功率(%)
5036 * @param y 配置したいフロアのY座標
5037 * @param x 配置したいフロアのX座標
5038 * @return 生成に成功したらTRUEを返す。
5040 * The initial location is assumed to be "in_bounds()".\n
5042 * This function takes a parameter "chance". This is the percentage\n
5043 * chance that the item will "disappear" instead of drop. If the object\n
5044 * has been thrown, then this is the chance of disappearance on contact.\n
5046 * Hack -- this function uses "chance" to determine if it should produce\n
5047 * some form of "description" of the drop event (under the player).\n
5049 * We check several locations to see if we can find a location at which\n
5050 * the object can combine, stack, or be placed. Artifacts will try very\n
5051 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5053 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5064 s16b this_o_idx, next_o_idx = 0;
5068 char o_name[MAX_NLEN];
5074 /* Extract plural */
5075 bool plural = (j_ptr->number != 1);
5078 /* Describe object */
5079 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5082 /* Handle normal "breakage" */
5083 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5087 msg_format("%sは消えた。", o_name);
5089 msg_format("The %s disappear%s.",
5090 o_name, (plural ? "" : "s"));
5095 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5112 /* Scan local grids */
5113 for (dy = -3; dy <= 3; dy++)
5115 /* Scan local grids */
5116 for (dx = -3; dx <= 3; dx++)
5120 /* Calculate actual distance */
5121 d = (dy * dy) + (dx * dx);
5123 /* Ignore distant grids */
5124 if (d > 10) continue;
5130 /* Skip illegal grids */
5131 if (!in_bounds(ty, tx)) continue;
5133 /* Require line of projection */
5134 if (!projectable(y, x, ty, tx)) continue;
5137 c_ptr = &cave[ty][tx];
5139 /* Require floor space */
5140 if (!cave_drop_bold(ty, tx)) continue;
5145 /* Scan objects in that grid */
5146 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5150 /* Acquire object */
5151 o_ptr = &o_list[this_o_idx];
5153 /* Acquire next object */
5154 next_o_idx = o_ptr->next_o_idx;
5156 /* Check for possible combination */
5157 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5163 /* Add new object */
5167 if (k > 99) continue;
5169 /* Calculate score */
5170 s = 1000 - (d + k * 5);
5172 /* Skip bad values */
5173 if (s < bs) continue;
5175 /* New best value */
5178 /* Apply the randomizer to equivalent values */
5179 if ((++bn >= 2) && !one_in_(bn)) continue;
5194 /* Handle lack of space */
5195 if (!flag && !object_is_artifact(j_ptr))
5199 msg_format("%sは消えた。", o_name);
5201 msg_format("The %s disappear%s.",
5202 o_name, (plural ? "" : "s"));
5207 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5215 for (i = 0; !flag && (i < 1000); i++)
5218 ty = rand_spread(by, 1);
5219 tx = rand_spread(bx, 1);
5221 /* Verify location */
5222 if (!in_bounds(ty, tx)) continue;
5224 /* Bounce to that location */
5228 /* Require floor space */
5229 if (!cave_drop_bold(by, bx)) continue;
5238 int candidates = 0, pick;
5240 for (ty = 1; ty < cur_hgt - 1; ty++)
5242 for (tx = 1; tx < cur_wid - 1; tx++)
5244 /* A valid space found */
5245 if (cave_drop_bold(ty, tx)) candidates++;
5249 /* No valid place! */
5254 msg_format("%sは消えた。", o_name);
5256 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5260 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5262 /* Mega-Hack -- preserve artifacts */
5265 /* Hack -- Preserve unknown artifacts */
5266 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5268 /* Mega-Hack -- Preserve the artifact */
5269 a_info[j_ptr->name1].cur_num = 0;
5277 /* Choose a random one */
5278 pick = randint1(candidates);
5280 for (ty = 1; ty < cur_hgt - 1; ty++)
5282 for (tx = 1; tx < cur_wid - 1; tx++)
5284 if (cave_drop_bold(ty, tx))
5288 /* Is this a picked one? */
5302 c_ptr = &cave[by][bx];
5304 /* Scan objects in that grid for combination */
5305 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5309 /* Acquire object */
5310 o_ptr = &o_list[this_o_idx];
5312 /* Acquire next object */
5313 next_o_idx = o_ptr->next_o_idx;
5315 /* Check for combination */
5316 if (object_similar(o_ptr, j_ptr))
5318 /* Combine the items */
5319 object_absorb(o_ptr, j_ptr);
5329 /* Get new object */
5330 if (!done) o_idx = o_pop();
5333 if (!done && !o_idx)
5337 msg_format("%sは消えた。", o_name);
5339 msg_format("The %s disappear%s.",
5340 o_name, (plural ? "" : "s"));
5345 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5347 /* Hack -- Preserve artifacts */
5348 if (object_is_fixed_artifact(j_ptr))
5350 a_info[j_ptr->name1].cur_num = 0;
5360 /* Structure copy */
5361 object_copy(&o_list[o_idx], j_ptr);
5363 /* Access new object */
5364 j_ptr = &o_list[o_idx];
5371 j_ptr->held_m_idx = 0;
5374 j_ptr->next_o_idx = c_ptr->o_idx;
5376 /* Place the object */
5377 c_ptr->o_idx = o_idx;
5392 /* Mega-Hack -- no message if "dropped" by player */
5393 /* Message when an object falls under the player */
5394 if (chance && player_bold(by, bx))
5396 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5408 * Scatter some "great" objects near the player
5409 * @param y1 配置したいフロアのY座標
5410 * @param x1 配置したいフロアのX座標
5411 * @param num 獲得の処理回数
5412 * @param great TRUEならば必ず高級品以上を落とす
5413 * @param special TRUEならば必ず特別品を落とす
5414 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5417 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5420 object_type object_type_body;
5421 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5426 /* Get local object */
5427 i_ptr = &object_type_body;
5429 /* Wipe the object */
5432 /* Make a good (or great) object (if possible) */
5433 if (!make_object(i_ptr, mode)) continue;
5437 object_aware(i_ptr);
5438 object_known(i_ptr);
5441 /* Drop the object */
5442 (void)drop_near(i_ptr, -1, y1, x1);
5447 * Scatter some "amusing" objects near the player
5450 #define AMS_NOTHING 0x00 /* No restriction */
5451 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5452 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5453 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5454 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5458 OBJECT_TYPE_VALUE tval;
5459 OBJECT_SUBTYPE_VALUE sval;
5464 amuse_type amuse_info[] =
5466 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5467 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5468 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5469 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5470 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5471 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5472 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5473 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5474 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5475 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5476 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5477 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5478 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5485 * @param y1 配置したいフロアのY座標
5486 * @param x1 配置したいフロアのX座標
5487 * @param num 誰得の処理回数
5488 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5491 void amusement(int y1, int x1, int num, bool known)
5494 object_type object_type_body;
5497 for (n = 0; amuse_info[n].tval != 0; n++)
5499 t += amuse_info[n].prob;
5506 IDX k_idx, a_idx = 0;
5507 int r = randint0(t);
5508 bool insta_art, fixed_art;
5512 r -= amuse_info[i].prob;
5516 /* Get local object */
5517 i_ptr = &object_type_body;
5519 /* Wipe the object */
5522 /* Wipe the object */
5523 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5525 /* Paranoia - reroll if nothing */
5526 if (!k_idx) continue;
5528 /* Search an artifact index if need */
5529 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5530 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5532 if (insta_art || fixed_art)
5534 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5536 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5537 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5538 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5539 if (a_info[a_idx].cur_num > 0) continue;
5543 if (a_idx >= max_a_idx) continue;
5546 /* Make an object (if possible) */
5547 object_prep(i_ptr, k_idx);
5548 if (a_idx) i_ptr->name1 = a_idx;
5549 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5551 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5553 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5556 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5557 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5561 object_aware(i_ptr);
5562 object_known(i_ptr);
5565 /* Paranoia - reroll if nothing */
5566 if (!(i_ptr->k_idx)) continue;
5568 /* Drop the object */
5569 (void)drop_near(i_ptr, -1, y1, x1);
5576 #define MAX_NORMAL_TRAPS 18
5578 /* See init_feat_variables() in init2.c */
5579 static s16b normal_traps[MAX_NORMAL_TRAPS];
5582 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5585 void init_normal_traps(void)
5589 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5590 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5591 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5592 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5593 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5594 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5595 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5596 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5597 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5598 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5599 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5600 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5601 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5602 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5603 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5604 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5605 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5606 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5610 * @brief 基本トラップをランダムに選択する /
5612 * @return 選択したトラップのID
5614 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5615 * That is, it does not make sense to have spiked pits at 50 feet.\n
5616 * Actually, it is not this routine, but the "trap instantiation"\n
5617 * code, which should also check for "trap doors" on quest levels.\n
5619 s16b choose_random_trap(void)
5626 /* Hack -- pick a trap */
5627 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5629 /* Accept non-trapdoors */
5630 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5632 /* Hack -- no trap doors on special levels */
5633 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5635 /* Hack -- no trap doors on the deepest level */
5636 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5645 * @brief マスに存在するトラップを秘匿する /
5646 * Disclose an invisible trap
5647 * @param y 秘匿したいマスのY座標
5648 * @param x 秘匿したいマスのX座標
5651 void disclose_grid(int y, int x)
5653 cave_type *c_ptr = &cave[y][x];
5655 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5657 /* No longer hidden */
5658 cave_alter_feat(y, x, FF_SECRET);
5660 else if (c_ptr->mimic)
5662 /* No longer hidden */
5674 * @brief マスをトラップを配置する /
5675 * The location must be a legal, naked, floor grid.
5676 * @param y 配置したいマスのY座標
5677 * @param x 配置したいマスのX座標
5679 * Note that all traps start out as "invisible" and "untyped", and then\n
5680 * when they are "discovered" (by detecting them or setting them off),\n
5681 * the trap is "instantiated" as a visible, "typed", trap.\n
5683 void place_trap(int y, int x)
5685 cave_type *c_ptr = &cave[y][x];
5687 /* Paranoia -- verify location */
5688 if (!in_bounds(y, x)) return;
5690 /* Require empty, clean, floor grid */
5691 if (!cave_clean_bold(y, x)) return;
5693 /* Place an invisible trap */
5694 c_ptr->mimic = c_ptr->feat;
5695 c_ptr->feat = choose_random_trap();
5699 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5700 * Describe the charges on an item in the inventory.
5701 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5704 void inven_item_charges(int item)
5706 object_type *o_ptr = &inventory[item];
5708 /* Require staff/wand */
5709 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5711 /* Require known item */
5712 if (!object_is_known(o_ptr)) return;
5715 if (o_ptr->pval <= 0)
5717 msg_print("もう魔力が残っていない。");
5721 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5724 /* Multiple charges */
5725 if (o_ptr->pval != 1)
5727 /* Print a message */
5728 msg_format("You have %d charges remaining.", o_ptr->pval);
5734 /* Print a message */
5735 msg_format("You have %d charge remaining.", o_ptr->pval);
5742 * @brief アイテムの残り所持数メッセージを表示する /
5743 * Describe an item in the inventory.
5744 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5747 void inven_item_describe(int item)
5749 object_type *o_ptr = &inventory[item];
5750 char o_name[MAX_NLEN];
5752 /* Get a description */
5753 object_desc(o_name, o_ptr, 0);
5755 /* Print a message */
5757 /* "no more" の場合はこちらで表示する */
5758 if (o_ptr->number <= 0)
5760 /*FIRST*//*ここはもう通らないかも */
5761 msg_format("もう%sを持っていない。", o_name);
5765 /* アイテム名を英日切り替え機能対応 */
5766 msg_format("まだ %sを持っている。", o_name);
5769 msg_format("You have %s.", o_name);
5775 * @brief アイテムの残り所持数メッセージを表示する /
5776 * Increase the "number" of an item in the inventory
5777 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5781 void inven_item_increase(int item, int num)
5783 object_type *o_ptr = &inventory[item];
5786 num += o_ptr->number;
5789 if (num > 255) num = 255;
5790 else if (num < 0) num = 0;
5793 num -= (ITEM_NUMBER)o_ptr->number;
5795 /* Change the number and weight */
5798 /* Add the number */
5799 o_ptr->number += num;
5801 /* Add the weight */
5802 p_ptr->total_weight += (num * o_ptr->weight);
5804 /* Recalculate bonuses */
5805 p_ptr->update |= (PU_BONUS);
5807 /* Recalculate mana XXX */
5808 p_ptr->update |= (PU_MANA);
5810 /* Combine the pack */
5811 p_ptr->notice |= (PN_COMBINE);
5814 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5816 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5817 if (!o_ptr->number && p_ptr->ele_attack)
5819 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5821 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5823 /* Clear all temporary elemental brands */
5824 set_ele_attack(0, 0);
5832 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5833 * Erase an inventory slot if it has no more items
5834 * @param item 消去したいプレイヤーのアイテム所持スロット
5837 void inven_item_optimize(int item)
5839 object_type *o_ptr = &inventory[item];
5841 /* Only optimize real items */
5842 if (!o_ptr->k_idx) return;
5844 /* Only optimize empty items */
5845 if (o_ptr->number) return;
5847 /* The item is in the pack */
5848 if (item < INVEN_RARM)
5855 /* Slide everything down */
5856 for (i = item; i < INVEN_PACK; i++)
5858 /* Structure copy */
5859 inventory[i] = inventory[i+1];
5862 /* Erase the "final" slot */
5863 object_wipe(&inventory[i]);
5866 p_ptr->window |= (PW_INVEN);
5869 /* The item is being wielded */
5875 /* Erase the empty slot */
5876 object_wipe(&inventory[item]);
5878 /* Recalculate bonuses */
5879 p_ptr->update |= (PU_BONUS);
5881 /* Recalculate torch */
5882 p_ptr->update |= (PU_TORCH);
5884 /* Recalculate mana XXX */
5885 p_ptr->update |= (PU_MANA);
5888 p_ptr->window |= (PW_EQUIP);
5892 p_ptr->window |= (PW_SPELL);
5896 * @brief 床上の魔道具の残り残量メッセージを表示する /
5897 * Describe the charges on an item on the floor.
5898 * @param item メッセージの対象にしたいアイテム所持スロット
5901 void floor_item_charges(int item)
5903 object_type *o_ptr = &o_list[item];
5905 /* Require staff/wand */
5906 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5908 /* Require known item */
5909 if (!object_is_known(o_ptr)) return;
5912 if (o_ptr->pval <= 0)
5914 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5918 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5921 /* Multiple charges */
5922 if (o_ptr->pval != 1)
5924 /* Print a message */
5925 msg_format("There are %d charges remaining.", o_ptr->pval);
5931 /* Print a message */
5932 msg_format("There is %d charge remaining.", o_ptr->pval);
5939 * @brief 床上のアイテムの残り数メッセージを表示する /
5940 * Describe the charges on an item on the floor.
5941 * @param item メッセージの対象にしたいアイテム所持スロット
5944 void floor_item_describe(int item)
5946 object_type *o_ptr = &o_list[item];
5947 char o_name[MAX_NLEN];
5949 /* Get a description */
5950 object_desc(o_name, o_ptr, 0);
5952 /* Print a message */
5954 /* "no more" の場合はこちらで表示を分ける */
5955 if (o_ptr->number <= 0)
5957 msg_format("床上には、もう%sはない。", o_name);
5961 msg_format("床上には、まだ %sがある。", o_name);
5964 msg_format("You see %s.", o_name);
5971 * @brief 床上のアイテムの数を増やす /
5972 * Increase the "number" of an item on the floor
5973 * @param item 増やしたいアイテムの所持スロット
5974 * @param num 増やしたいアイテムの数
5977 void floor_item_increase(int item, int num)
5979 object_type *o_ptr = &o_list[item];
5982 num += o_ptr->number;
5985 if (num > 255) num = 255;
5986 else if (num < 0) num = 0;
5989 num -= (int)o_ptr->number;
5991 /* Change the number */
5992 o_ptr->number += (ITEM_NUMBER)num;
5997 * @brief 床上の数の無くなったアイテムスロットを消去する /
5998 * Optimize an item on the floor (destroy "empty" items)
5999 * @param item 消去したいアイテムの所持スロット
6002 void floor_item_optimize(int item)
6004 object_type *o_ptr = &o_list[item];
6006 /* Paranoia -- be sure it exists */
6007 if (!o_ptr->k_idx) return;
6009 /* Only optimize empty items */
6010 if (o_ptr->number) return;
6012 /* Delete the object */
6013 delete_object_idx(item);
6018 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6019 * Check if we have space for an item in the pack without overflow
6020 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6021 * @return 溢れずに済むならTRUEを返す
6023 bool inven_carry_okay(object_type *o_ptr)
6028 if (inven_cnt < INVEN_PACK) return (TRUE);
6031 for (j = 0; j < INVEN_PACK; j++)
6033 object_type *j_ptr = &inventory[j];
6035 /* Skip non-objects */
6036 if (!j_ptr->k_idx) continue;
6038 /* Check if the two items can be combined */
6039 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6047 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6048 * Check if we have space for an item in the pack without overflow
6049 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6050 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6051 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6052 * @return o_ptrの方が上位ならばTRUEを返す。
6054 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6058 /* Use empty slots */
6059 if (!j_ptr->k_idx) return TRUE;
6061 /* Hack -- readable books always come first */
6062 if ((o_ptr->tval == REALM1_BOOK) &&
6063 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6064 if ((j_ptr->tval == REALM1_BOOK) &&
6065 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6067 if ((o_ptr->tval == REALM2_BOOK) &&
6068 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6069 if ((j_ptr->tval == REALM2_BOOK) &&
6070 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6072 /* Objects sort by decreasing type */
6073 if (o_ptr->tval > j_ptr->tval) return TRUE;
6074 if (o_ptr->tval < j_ptr->tval) return FALSE;
6076 /* Non-aware (flavored) items always come last */
6077 /* Can happen in the home */
6078 if (!object_is_aware(o_ptr)) return FALSE;
6079 if (!object_is_aware(j_ptr)) return TRUE;
6081 /* Objects sort by increasing sval */
6082 if (o_ptr->sval < j_ptr->sval) return TRUE;
6083 if (o_ptr->sval > j_ptr->sval) return FALSE;
6085 /* Unidentified objects always come last */
6086 /* Objects in the home can be unknown */
6087 if (!object_is_known(o_ptr)) return FALSE;
6088 if (!object_is_known(j_ptr)) return TRUE;
6090 /* Fixed artifacts, random artifacts and ego items */
6091 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6092 else if (o_ptr->art_name) o_type = 2;
6093 else if (object_is_ego(o_ptr)) o_type = 1;
6096 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6097 else if (j_ptr->art_name) j_type = 2;
6098 else if (object_is_ego(j_ptr)) j_type = 1;
6101 if (o_type < j_type) return TRUE;
6102 if (o_type > j_type) return FALSE;
6104 switch (o_ptr->tval)
6110 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6111 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6117 /* Objects sort by increasing hit/damage bonuses */
6118 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6119 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6122 /* Hack: otherwise identical rods sort by
6123 increasing recharge time --dsb */
6125 if (o_ptr->pval < j_ptr->pval) return TRUE;
6126 if (o_ptr->pval > j_ptr->pval) return FALSE;
6130 /* Objects sort by decreasing value */
6131 return o_value > object_value(j_ptr);
6136 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6137 * Add an item to the players inventory, and return the slot used.
6138 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6139 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6141 * If the new item can combine with an existing item in the inventory,\n
6142 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6143 * the item will be placed into the "proper" location in the inventory.\n
6145 * This function can be used to "over-fill" the player's pack, but only\n
6146 * once, and such an action must trigger the "overflow" code immediately.\n
6147 * Note that when the pack is being "over-filled", the new item must be\n
6148 * placed into the "overflow" slot, and the "overflow" must take place\n
6149 * before the pack is reordered, but (optionally) after the pack is\n
6150 * combined. This may be tricky. See "dungeon.c" for info.\n
6152 * Note that this code must remove any location/stack information\n
6153 * from the object once it is placed into the inventory.\n
6155 s16b inven_carry(object_type *o_ptr)
6157 INVENTORY_IDX i, j, k;
6158 INVENTORY_IDX n = -1;
6163 /* Check for combining */
6164 for (j = 0; j < INVEN_PACK; j++)
6166 j_ptr = &inventory[j];
6168 /* Skip non-objects */
6169 if (!j_ptr->k_idx) continue;
6171 /* Hack -- track last item */
6174 /* Check if the two items can be combined */
6175 if (object_similar(j_ptr, o_ptr))
6177 /* Combine the items */
6178 object_absorb(j_ptr, o_ptr);
6180 /* Increase the weight */
6181 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6183 /* Recalculate bonuses */
6184 p_ptr->update |= (PU_BONUS);
6187 p_ptr->window |= (PW_INVEN);
6196 if (inven_cnt > INVEN_PACK) return (-1);
6198 /* Find an empty slot */
6199 for (j = 0; j <= INVEN_PACK; j++)
6201 j_ptr = &inventory[j];
6203 /* Use it if found */
6204 if (!j_ptr->k_idx) break;
6211 /* Reorder the pack */
6214 /* Get the "value" of the item */
6215 s32b o_value = object_value(o_ptr);
6217 /* Scan every occupied slot */
6218 for (j = 0; j < INVEN_PACK; j++)
6220 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6227 for (k = n; k >= i; k--)
6229 /* Hack -- Slide the item */
6230 object_copy(&inventory[k+1], &inventory[k]);
6233 /* Wipe the empty slot */
6234 object_wipe(&inventory[i]);
6239 object_copy(&inventory[i], o_ptr);
6241 /* Access new object */
6242 j_ptr = &inventory[i];
6245 j_ptr->next_o_idx = 0;
6247 /* Forget monster */
6248 j_ptr->held_m_idx = 0;
6250 /* Forget location */
6251 j_ptr->iy = j_ptr->ix = 0;
6253 /* Player touches it, and no longer marked */
6254 j_ptr->marked = OM_TOUCHED;
6256 /* Increase the weight */
6257 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6259 /* Count the items */
6262 /* Recalculate bonuses */
6263 p_ptr->update |= (PU_BONUS);
6265 /* Combine and Reorder pack */
6266 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6269 p_ptr->window |= (PW_INVEN);
6271 /* Return the slot */
6277 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6278 * Take off (some of) a non-cursed equipment item
6279 * @param item オブジェクトを外したい所持テーブルのID
6281 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6283 * Note that only one item at a time can be wielded per slot.\n
6284 * Note that taking off an item when "full" may cause that item\n
6285 * to fall to the ground.\n
6286 * Return the inventory slot into which the item is placed.\n
6288 s16b inven_takeoff(int item, int amt)
6299 char o_name[MAX_NLEN];
6302 /* Get the item to take off */
6303 o_ptr = &inventory[item];
6306 if (amt <= 0) return (-1);
6309 if (amt > o_ptr->number) amt = o_ptr->number;
6311 /* Get local object */
6314 /* Obtain a local object */
6315 object_copy(q_ptr, o_ptr);
6317 /* Modify quantity */
6318 q_ptr->number = amt;
6320 /* Describe the object */
6321 object_desc(o_name, q_ptr, 0);
6323 /* Took off weapon */
6324 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6325 object_is_melee_weapon(o_ptr))
6327 act = _("を装備からはずした", "You were wielding");
6331 else if (item == INVEN_BOW)
6333 act = _("を装備からはずした", "You were holding");
6336 /* Took off light */
6337 else if (item == INVEN_LITE)
6339 act = _("を光源からはずした", "You were holding");
6342 /* Took off something */
6345 act = _("を装備からはずした", "You were wearing");
6348 /* Modify, Optimize */
6349 inven_item_increase(item, -amt);
6350 inven_item_optimize(item);
6352 /* Carry the object */
6353 slot = inven_carry(q_ptr);
6357 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6359 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6369 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6370 * Drop (some of) a non-cursed inventory/equipment item
6371 * @param item 所持テーブルのID
6372 * @param amt 落としたい個数
6375 * The object will be dropped "near" the current location
6377 void inven_drop(int item, int amt)
6384 char o_name[MAX_NLEN];
6387 /* Access original object */
6388 o_ptr = &inventory[item];
6391 if (amt <= 0) return;
6394 if (amt > o_ptr->number) amt = o_ptr->number;
6397 /* Take off equipment */
6398 if (item >= INVEN_RARM)
6400 /* Take off first */
6401 item = inven_takeoff(item, amt);
6403 /* Access original object */
6404 o_ptr = &inventory[item];
6408 /* Get local object */
6411 /* Obtain local object */
6412 object_copy(q_ptr, o_ptr);
6414 /* Distribute charges of wands or rods */
6415 distribute_charges(o_ptr, q_ptr, amt);
6417 /* Modify quantity */
6418 q_ptr->number = amt;
6420 /* Describe local object */
6421 object_desc(o_name, q_ptr, 0);
6424 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6426 /* Drop it near the player */
6427 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6429 /* Modify, Describe, Optimize */
6430 inven_item_increase(item, -amt);
6431 inven_item_describe(item);
6432 inven_item_optimize(item);
6437 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6438 * Combine items in the pack
6441 * Note special handling of the "overflow" slot
6443 void combine_pack(void)
6448 bool flag = FALSE, combined;
6454 /* Combine the pack (backwards) */
6455 for (i = INVEN_PACK; i > 0; i--)
6458 o_ptr = &inventory[i];
6460 /* Skip empty items */
6461 if (!o_ptr->k_idx) continue;
6463 /* Scan the items above that item */
6464 for (j = 0; j < i; j++)
6469 j_ptr = &inventory[j];
6471 /* Skip empty items */
6472 if (!j_ptr->k_idx) continue;
6475 * Get maximum number of the stack if these
6476 * are similar, get zero otherwise.
6478 max_num = object_similar_part(j_ptr, o_ptr);
6480 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6481 if (max_num && j_ptr->number < max_num)
6483 if (o_ptr->number + j_ptr->number <= max_num)
6488 /* Add together the item counts */
6489 object_absorb(j_ptr, o_ptr);
6491 /* One object is gone */
6494 /* Slide everything down */
6495 for (k = i; k < INVEN_PACK; k++)
6497 /* Structure copy */
6498 inventory[k] = inventory[k+1];
6501 /* Erase the "final" slot */
6502 object_wipe(&inventory[k]);
6506 int old_num = o_ptr->number;
6507 int remain = j_ptr->number + o_ptr->number - max_num;
6509 o_ptr->number -= remain;
6511 /* Add together the item counts */
6512 object_absorb(j_ptr, o_ptr);
6514 o_ptr->number = remain;
6516 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6517 if (o_ptr->tval == TV_ROD)
6519 o_ptr->pval = o_ptr->pval * remain / old_num;
6520 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6523 /* Hack -- if wands are stacking, combine the charges. -LM- */
6524 if (o_ptr->tval == TV_WAND)
6526 o_ptr->pval = o_ptr->pval * remain / old_num;
6531 p_ptr->window |= (PW_INVEN);
6545 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6549 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6550 * Reorder items in the pack
6553 * Note special handling of the "overflow" slot
6555 void reorder_pack(void)
6565 /* Re-order the pack (forwards) */
6566 for (i = 0; i < INVEN_PACK; i++)
6568 /* Mega-Hack -- allow "proper" over-flow */
6569 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6572 o_ptr = &inventory[i];
6574 /* Skip empty slots */
6575 if (!o_ptr->k_idx) continue;
6577 /* Get the "value" of the item */
6578 o_value = object_value(o_ptr);
6580 /* Scan every occupied slot */
6581 for (j = 0; j < INVEN_PACK; j++)
6583 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6586 /* Never move down */
6587 if (j >= i) continue;
6592 /* Get local object */
6595 /* Save a copy of the moving item */
6596 object_copy(q_ptr, &inventory[i]);
6598 /* Slide the objects */
6599 for (k = i; k > j; k--)
6601 /* Slide the item */
6602 object_copy(&inventory[k], &inventory[k-1]);
6605 /* Insert the moving item */
6606 object_copy(&inventory[j], q_ptr);
6609 p_ptr->window |= (PW_INVEN);
6613 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6617 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6618 * Hack -- display an object kind in the current window
6619 * @param k_idx ベースアイテムの参照ID
6622 * Include list of usable spells for readible books
6624 void display_koff(IDX k_idx)
6631 REALM_IDX use_realm;
6633 char o_name[MAX_NLEN];
6636 /* Erase the window */
6637 for (y = 0; y < Term->hgt; y++)
6639 /* Erase the line */
6640 Term_erase(0, y, 255);
6646 /* Get local object */
6649 /* Prepare the object */
6650 object_prep(q_ptr, k_idx);
6653 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6655 /* Mention the object name */
6656 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6658 /* Access the item's sval */
6660 use_realm = tval2realm(q_ptr->tval);
6662 /* Warriors are illiterate */
6663 if (p_ptr->realm1 || p_ptr->realm2)
6665 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6669 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6670 if (!is_magic(use_realm)) return;
6671 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6674 /* Display spells in readible books */
6678 SPELL_IDX spells[64];
6680 /* Extract spells */
6681 for (spell = 0; spell < 32; spell++)
6683 /* Check for this spell */
6684 if (fake_spell_flags[sval] & (1L << spell))
6686 /* Collect this spell */
6687 spells[num++] = spell;
6692 print_spells(0, spells, num, 2, 0, use_realm);
6697 * @brief 警告を放つアイテムを選択する /
6698 * Choose one of items that have warning flag
6699 * Calculate spell damages
6702 object_type *choose_warning_item(void)
6705 int choices[INVEN_TOTAL - INVEN_RARM];
6708 /* Paranoia -- Player has no warning ability */
6709 if (!p_ptr->warning) return NULL;
6711 /* Search Inventory */
6712 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6714 u32b flgs[TR_FLAG_SIZE];
6715 object_type *o_ptr = &inventory[i];
6717 object_flags(o_ptr, flgs);
6718 if (have_flag(flgs, TR_WARNING))
6720 choices[number] = i;
6725 /* Choice one of them */
6726 return number ? &inventory[choices[randint0(number)]] : NULL;
6730 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6731 * Calculate spell damages
6732 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6733 * @param typ 効果属性のID
6735 * @param max 算出した最大ダメージを返すポインタ
6738 static void spell_damcalc(monster_type *m_ptr, int typ, HIT_POINT dam, int *max)
6740 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6741 int rlev = r_ptr->level;
6742 bool ignore_wraith_form = FALSE;
6744 /* Vulnerability, resistance and immunity */
6748 if (p_ptr->immune_elec)
6751 ignore_wraith_form = TRUE;
6755 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6756 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6757 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6758 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6759 if (IS_OPPOSE_ELEC())
6760 dam = (dam + 2) / 3;
6765 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6766 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6770 if (p_ptr->immune_acid)
6773 ignore_wraith_form = TRUE;
6777 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6778 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6779 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6780 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6786 if (p_ptr->immune_cold)
6789 ignore_wraith_form = TRUE;
6793 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6794 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6795 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6796 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6801 if (p_ptr->immune_fire)
6804 ignore_wraith_form = TRUE;
6808 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6809 if (prace_is_(RACE_ENT)) dam += dam / 3;
6810 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6811 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6812 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6817 ignore_wraith_form = TRUE;
6821 if (!p_ptr->blind &&
6822 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6823 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6826 ignore_wraith_form = TRUE;
6831 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6832 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6833 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6836 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6837 * "dam *= 2;" for later "dam /= 2"
6839 if (p_ptr->wraith_form) dam *= 2;
6843 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6846 ignore_wraith_form = TRUE;
6848 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6852 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6856 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6860 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6864 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6868 if (prace_is_(RACE_SPECTRE))
6871 ignore_wraith_form = TRUE;
6873 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6877 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6881 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6885 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6889 if (p_ptr->levitation) dam = (dam * 2) / 3;
6893 if (p_ptr->resist_shard) dam /= 2;
6897 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6898 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6902 if (p_ptr->mimic_form)
6904 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6907 ignore_wraith_form = TRUE;
6912 switch (p_ptr->prace)
6921 ignore_wraith_form = TRUE;
6928 if (p_ptr->align > 10) dam /= 2;
6929 else if (p_ptr->align < -10) dam *= 2;
6933 if (p_ptr->align > 10) dam *= 2;
6937 case GF_BRAIN_SMASH:
6938 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6941 ignore_wraith_form = TRUE;
6949 if (100 + rlev / 2 <= p_ptr->skill_sav)
6952 ignore_wraith_form = TRUE;
6957 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6960 ignore_wraith_form = TRUE;
6965 if (p_ptr->wraith_form && !ignore_wraith_form)
6971 if (dam > *max) *max = dam;
6975 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6976 * Calculate spell damages
6977 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6978 * @param typ 効果属性のID
6979 * @param m_idx 魔法を行使するモンスターのID
6980 * @param max 算出した最大ダメージを返すポインタ
6983 void spell_damcalc_by_spellnum(int spell_num, int typ, MONSTER_IDX m_idx, int *max)
6985 monster_type *m_ptr = &m_list[m_idx];
6986 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
6987 spell_damcalc(m_ptr, typ, dam, max);
6991 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
6992 * Calculate blow damages
6993 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
6994 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
6995 * @return 算出された最大ダメージを返す。
6997 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6999 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7001 bool check_wraith_form = TRUE;
7003 if (blow_ptr->method != RBM_EXPLODE)
7005 int ac = p_ptr->ac + p_ptr->to_a;
7007 switch (blow_ptr->effect)
7011 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7012 dam = MAX(dam, tmp_dam * 2);
7018 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7022 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7024 check_wraith_form = FALSE;
7028 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7030 check_wraith_form = FALSE;
7034 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7036 check_wraith_form = FALSE;
7040 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7042 check_wraith_form = FALSE;
7047 check_wraith_form = FALSE;
7051 if (check_wraith_form && p_ptr->wraith_form)
7059 dam = (dam + 1) / 2;
7060 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7068 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7069 * Examine the grid (xx,yy) and warn the player if there are any danger
7070 * @param xx 危険性を調査するマスのX座標
7071 * @param yy 危険性を調査するマスのY座標
7072 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7074 bool process_warning(int xx, int yy)
7078 char o_name[MAX_NLEN];
7080 #define WARNING_AWARE_RANGE 12
7082 static int old_damage = 0;
7084 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7086 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7089 monster_type *m_ptr;
7090 monster_race *r_ptr;
7092 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7094 c_ptr = &cave[my][mx];
7096 if (!c_ptr->m_idx) continue;
7098 m_ptr = &m_list[c_ptr->m_idx];
7100 if (MON_CSLEEP(m_ptr)) continue;
7101 if (!is_hostile(m_ptr)) continue;
7103 r_ptr = &r_info[m_ptr->r_idx];
7105 /* Monster spells (only powerful ones)*/
7106 if (projectable(my, mx, yy, xx))
7108 u32b f4 = r_ptr->flags4;
7109 u32b f5 = r_ptr->a_ability_flags1;
7110 u32b f6 = r_ptr->a_ability_flags2;
7112 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7114 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7115 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7116 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7117 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7118 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7119 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7121 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7122 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7123 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7124 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7125 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7126 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7127 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7128 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7129 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7130 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7131 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7132 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7133 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7134 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7135 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7136 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7137 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7138 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7139 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7140 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7141 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7142 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7143 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7146 /* Monster melee attacks */
7147 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7149 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7153 for (m = 0; m < 4; m++)
7155 /* Skip non-attacks */
7156 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7158 /* Extract the attack info */
7159 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7160 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7162 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7166 /* Contribution from this monster */
7167 dam_max += dam_max0;
7171 /* Prevent excessive warning */
7172 if (dam_max > old_damage)
7174 old_damage = dam_max * 3 / 2;
7176 if (dam_max > p_ptr->chp / 2)
7178 object_type *o_ptr = choose_warning_item();
7181 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7183 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7184 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7187 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7190 else old_damage = old_damage / 2;
7192 c_ptr = &cave[yy][xx];
7193 if (((!easy_disarm && is_trap(c_ptr->feat))
7194 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7196 object_type *o_ptr = choose_warning_item();
7199 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7201 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7202 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7204 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7211 * @brief エッセンスの付加可能な武器や矢弾かを返す
7212 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7213 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7215 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7217 switch (o_ptr->tval)
7230 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7239 * エッセンス情報の構造体 / A structure for smithing
7242 int add; /* TR flag number or special essence id */
7243 cptr add_name; /* Name of this ability */
7244 int type; /* Menu number */
7245 int essence; /* Index for carrying essences */
7246 int value; /* Needed value to add this ability */
7251 * エッセンス情報テーブル Smithing type data for Weapon smith
7254 static essence_type essence_info[] =
7256 {TR_STR, "腕力", 4, TR_STR, 20},
7257 {TR_INT, "知能", 4, TR_INT, 20},
7258 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7259 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7260 {TR_CON, "耐久力", 4, TR_CON, 20},
7261 {TR_CHR, "魅力", 4, TR_CHR, 20},
7262 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7263 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7264 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7265 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7266 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7267 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7268 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7269 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7270 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7271 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7272 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7273 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7274 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7275 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7276 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7277 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7278 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7279 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7280 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7281 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7282 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7283 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7284 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7285 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7286 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7287 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7288 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7289 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7290 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7291 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7292 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7293 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7294 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7295 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7296 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7297 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7298 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7299 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7300 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7301 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7302 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7303 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7304 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7305 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7306 {TR_SH_FIRE, "", 0, -2, 0},
7307 {TR_SH_ELEC, "", 0, -2, 0},
7308 {TR_SH_COLD, "", 0, -2, 0},
7309 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7310 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7311 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7312 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7313 {TR_LITE_2, "", 0, -2, 0},
7314 {TR_LITE_3, "", 0, -2, 0},
7315 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7316 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7317 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7318 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7319 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7321 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7322 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7323 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7324 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7325 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7326 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7327 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7328 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7329 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7330 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7331 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7332 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7333 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7334 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7335 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7336 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7337 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7338 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7340 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7341 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7342 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7343 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7344 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7345 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7346 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7347 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7349 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7350 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7351 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7352 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7353 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7354 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7355 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7356 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7357 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7358 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7359 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7360 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7362 {-1, NULL, 0, -1, 0}
7365 static essence_type essence_info[] =
7367 {TR_STR, "strength", 4, TR_STR, 20},
7368 {TR_INT, "intelligence", 4, TR_INT, 20},
7369 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7370 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7371 {TR_CON, "constitution", 4, TR_CON, 20},
7372 {TR_CHR, "charisma", 4, TR_CHR, 20},
7373 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7374 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7375 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7376 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7377 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7378 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7379 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7380 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7381 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7382 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7383 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7384 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7385 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7386 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7387 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7388 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7389 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7390 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7391 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7392 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7393 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7394 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7395 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7396 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7397 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7398 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7399 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7400 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7401 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7402 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7403 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7404 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7405 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7406 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7407 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7408 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7409 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7410 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7411 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7412 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7413 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7414 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7415 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7416 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7417 {TR_SH_FIRE, "", 0, -2, 0},
7418 {TR_SH_ELEC, "", 0, -2, 0},
7419 {TR_SH_COLD, "", 0, -2, 0},
7420 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7421 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7422 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7423 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7424 {TR_LITE_2, "", 0, -2, 0},
7425 {TR_LITE_3, "", 0, -2, 0},
7426 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7427 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7428 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7429 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7430 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7432 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7433 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7434 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7435 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7436 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7437 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7438 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7439 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7440 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7441 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7442 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7443 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7444 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7445 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7446 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7447 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7448 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7449 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7451 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7452 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7453 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7454 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7455 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7456 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7457 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7458 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7460 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7461 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7462 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7463 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7464 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7465 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7466 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7467 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7468 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7469 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7470 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7471 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7473 {-1, NULL, 0, -1, 0}
7479 * エッセンス名テーブル / Essense names for Weapon smith
7482 cptr essence_name[] =
7585 cptr essence_name[] =
7688 * @brief 所持しているエッセンス一覧を表示する
7691 static void display_essence(void)
7696 for (i = 1; i < 22; i++)
7700 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7701 "Essence Num Essence Num Essence Num "), 1, 8);
7702 for (i = 0; essence_name[i]; i++)
7704 if (!essence_name[i][0]) continue;
7705 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7708 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7718 static void drain_essence(void)
7720 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7724 bool observe = FALSE;
7725 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
7726 TIME_EFFECT old_timeout;
7727 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7733 s16b next_o_idx, weight;
7735 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7738 item_tester_hook = object_is_weapon_armour_ammo;
7739 item_tester_no_ryoute = TRUE;
7742 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7743 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7745 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7747 /* Get the item (in the pack) */
7750 o_ptr = &inventory[item];
7753 /* Get the item (on the floor) */
7756 o_ptr = &o_list[0 - item];
7759 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7761 char o_name[MAX_NLEN];
7762 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7763 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7766 p_ptr->energy_use = 100;
7768 object_flags(o_ptr, old_flgs);
7769 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7770 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7771 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7772 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7773 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7774 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7775 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7776 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7777 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7779 old_to_a = o_ptr->to_a;
7781 old_to_h = o_ptr->to_h;
7782 old_to_d = o_ptr->to_d;
7785 old_pval = o_ptr->pval;
7786 old_name2 = o_ptr->name2;
7787 old_timeout = o_ptr->timeout;
7788 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7789 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7790 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7791 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7792 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7793 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7794 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7795 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7796 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7797 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7798 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7799 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7800 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7801 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7802 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7803 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7804 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7805 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7806 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7810 next_o_idx = o_ptr->next_o_idx;
7811 marked = o_ptr->marked;
7812 weight = o_ptr->weight;
7813 number = o_ptr->number;
7815 object_prep(o_ptr, o_ptr->k_idx);
7819 o_ptr->next_o_idx=next_o_idx;
7820 o_ptr->marked=marked;
7821 o_ptr->number = number;
7822 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7823 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7824 o_ptr->ident |= (IDENT_MENTAL);
7825 object_aware(o_ptr);
7826 object_known(o_ptr);
7828 object_flags(o_ptr, new_flgs);
7830 for (i = 0; essence_info[i].add_name; i++)
7832 essence_type *es_ptr = &essence_info[i];
7833 PARAMETER_VALUE pval = 0;
7835 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7836 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7838 if (es_ptr->add < TR_FLAG_MAX &&
7839 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7840 have_flag(old_flgs, es_ptr->add))
7844 drain_value[es_ptr->essence] += 10 * pval;
7846 else if (es_ptr->essence != -2)
7848 drain_value[es_ptr->essence] += 10;
7850 else if (es_ptr->add == TR_SH_FIRE)
7852 drain_value[TR_BRAND_FIRE] += 10;
7853 drain_value[TR_RES_FIRE] += 10;
7855 else if (es_ptr->add == TR_SH_ELEC)
7857 drain_value[TR_BRAND_ELEC] += 10;
7858 drain_value[TR_RES_ELEC] += 10;
7860 else if (es_ptr->add == TR_SH_COLD)
7862 drain_value[TR_BRAND_COLD] += 10;
7863 drain_value[TR_RES_COLD] += 10;
7865 else if (es_ptr->add == TR_LITE_2)
7867 drain_value[TR_LITE_1] += 20;
7869 else if (es_ptr->add == TR_LITE_3)
7871 drain_value[TR_LITE_1] += 30;
7876 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7878 drain_value[TR_INT] += 5;
7879 drain_value[TR_WIS] += 5;
7881 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7883 drain_value[TR_BRAND_POIS] += 5;
7884 drain_value[TR_BRAND_ACID] += 5;
7885 drain_value[TR_BRAND_ELEC] += 5;
7886 drain_value[TR_BRAND_FIRE] += 5;
7887 drain_value[TR_BRAND_COLD] += 5;
7889 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7891 drain_value[TR_INT] += 10;
7893 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7895 drain_value[TR_STR] += 10;
7897 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7899 drain_value[TR_DEX] += 10;
7901 if (old_name2 == EGO_2WEAPON)
7903 drain_value[TR_DEX] += 20;
7905 if (object_is_weapon_ammo(o_ptr))
7907 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7909 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7911 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7912 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7913 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7914 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7916 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7918 drain_value[i] *= number;
7919 drain_value[i] = drain_value[i] * dec / 4;
7920 drain_value[i] = MAX(drain_value[i], 0);
7921 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7929 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7933 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7935 for (i = 0; essence_name[i]; i++)
7937 if (!essence_name[i][0]) continue;
7938 if (!drain_value[i]) continue;
7940 p_ptr->magic_num1[i] += drain_value[i];
7941 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7943 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7947 /* Apply autodestroy/inscription to the drained item */
7948 autopick_alter_item(item, TRUE);
7950 /* Combine the pack */
7951 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7954 p_ptr->window |= (PW_INVEN);
7958 * @brief 付加するエッセンスの大別を選択する
7959 * @return 選んだエッセンスの大別ID
7961 static int choose_essence(void)
7963 COMMAND_CODE mode = 0;
7965 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
7968 cptr menu_name[] = {
7978 cptr menu_name[] = {
7988 const int mode_max = 7;
7991 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7994 #endif /* ALLOW_REPEAT */
8003 for (i = 0; i < mode_max; i++)
8005 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8006 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8008 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8009 prt("Choose from menu.", 0, 0);
8028 menu_line += mode_max - 1;
8037 if (menu_line > mode_max) menu_line -= mode_max;
8048 for (i = 0; i < mode_max; i++)
8049 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8051 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8057 if (isupper(choice)) choice = (char)tolower(choice);
8059 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8060 mode = (int)choice - 'a' + 1;
8067 #endif /* ALLOW_REPEAT */
8072 * @brief エッセンスを実際に付加する
8073 * @param mode エッセンスの大別ID
8076 static void add_essence(int mode)
8088 char o_name[MAX_NLEN];
8090 essence_type *es_ptr;
8092 int menu_line = (use_menu ? 1 : 0);
8094 for (i = 0; essence_info[i].add_name; i++)
8096 es_ptr = &essence_info[i];
8098 if (es_ptr->type != mode) continue;
8103 if (!repeat_pull(&i) || i<0 || i>=max_num)
8105 #endif /* ALLOW_REPEAT */
8108 /* Nothing chosen yet */
8114 /* Build a prompt */
8115 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8116 if (use_menu) screen_save();
8118 /* Get a spell from the user */
8120 choice = (always_show_list || use_menu) ? ESCAPE:1;
8124 if( choice==ESCAPE ) choice = ' ';
8125 else if( !get_com(out_val, &choice, FALSE) )break;
8127 if (use_menu && choice != ' ')
8141 menu_line += (max_num-1);
8164 menu_line = max_num;
8178 if (menu_line > max_num) menu_line -= max_num;
8180 /* Request redraw */
8181 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8184 if (!redraw || use_menu)
8188 char dummy[80], dummy2[80];
8196 /* Save the screen */
8197 if (!use_menu) screen_save();
8199 for (y = 1; y < 24; y++)
8202 /* Print header(s) */
8204 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8207 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8210 for (ctr = 0; ctr < max_num; ctr++)
8212 es_ptr = &essence_info[num[ctr]];
8216 if (ctr == (menu_line-1))
8217 strcpy(dummy, _("》 ", "> "));
8218 else strcpy(dummy, " ");
8221 /* letter/number for power selection */
8224 sprintf(dummy, "%c) ",I2A(ctr));
8227 strcat(dummy, es_ptr->add_name);
8232 if (es_ptr->essence != -1)
8234 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8235 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8241 case ESSENCE_SH_FIRE:
8242 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8243 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8244 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8246 case ESSENCE_SH_ELEC:
8247 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8248 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8249 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8251 case ESSENCE_SH_COLD:
8252 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8253 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8254 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8256 case ESSENCE_RESISTANCE:
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;
8263 case ESSENCE_SUSTAIN:
8264 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8265 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8266 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8267 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8268 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8273 if (!able[ctr]) col = TERM_RED;
8275 if (es_ptr->essence != -1)
8277 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8281 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8284 c_prt(col, dummy2, ctr+2, x);
8294 /* Restore the screen */
8305 ask = (isupper(choice));
8308 if (ask) choice = (char)tolower(choice);
8310 /* Extract request */
8311 i = (islower(choice) ? A2I(choice) : -1);
8314 /* Totally Illegal */
8315 if ((i < 0) || (i >= max_num) || !able[i])
8327 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8329 /* Belay that order */
8330 if (!get_check(tmp_val)) continue;
8337 /* Restore the screen */
8338 if (redraw) screen_load();
8345 #endif /* ALLOW_REPEAT */
8347 es_ptr = &essence_info[num[i]];
8349 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8350 item_tester_tval = TV_GLOVES;
8351 else if (mode == 1 || mode == 5)
8352 item_tester_hook = item_tester_hook_melee_ammo;
8353 else if (es_ptr->add == ESSENCE_ATTACK)
8354 item_tester_hook = object_allow_enchant_weapon;
8355 else if (es_ptr->add == ESSENCE_AC)
8356 item_tester_hook = object_is_armour;
8358 item_tester_hook = object_is_weapon_armour_ammo;
8359 item_tester_no_ryoute = TRUE;
8362 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8363 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8365 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8367 /* Get the item (in the pack) */
8370 o_ptr = &inventory[item];
8373 /* Get the item (on the floor) */
8376 o_ptr = &o_list[0 - item];
8379 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8381 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8385 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8387 use_essence = es_ptr->value;
8388 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8389 if (o_ptr->number > 1)
8391 use_essence *= o_ptr->number;
8392 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8395 if (es_ptr->essence != -1)
8397 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8399 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8402 if (is_pval_flag(es_ptr->add))
8404 if (o_ptr->pval < 0)
8406 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8409 else if (es_ptr->add == TR_BLOWS)
8411 if (o_ptr->pval > 1)
8413 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8417 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8419 else if (o_ptr->pval > 0)
8421 use_essence *= o_ptr->pval;
8422 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8428 PARAMETER_VALUE pval;
8429 PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8431 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8432 strcpy(tmp_val, "1");
8434 if (!get_string(tmp, tmp_val, 1)) return;
8435 pval = (PARAMETER_VALUE)atoi(tmp_val);
8436 if (pval > limit) pval = limit;
8437 else if (pval < 1) pval = 1;
8438 o_ptr->pval += pval;
8439 use_essence *= pval;
8440 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8443 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8445 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8449 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8456 strcpy(tmp_val, "1");
8457 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8458 val = atoi(tmp_val);
8459 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8460 else if (val < 1) val = 1;
8462 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8463 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8465 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8468 get_to_h = ((val+1)/2+randint0(val/2+1));
8469 get_to_d = ((val+1)/2+randint0(val/2+1));
8470 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8471 o_ptr->to_h += get_to_h;
8472 o_ptr->to_d += get_to_d;
8474 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8475 if (es_ptr->add == ESSENCE_ATTACK)
8477 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8479 msg_print(_("改良に失敗した。", "You failed to enchant."));
8480 p_ptr->energy_use = 100;
8485 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8486 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8489 else if (es_ptr->add == ESSENCE_AC)
8491 if (o_ptr->to_a >= p_ptr->lev/5+5)
8493 msg_print(_("改良に失敗した。", "You failed to enchant."));
8494 p_ptr->energy_use = 100;
8499 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8504 o_ptr->xtra3 = es_ptr->add + 1;
8509 bool success = TRUE;
8513 case ESSENCE_SH_FIRE:
8514 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8519 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8520 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8522 case ESSENCE_SH_ELEC:
8523 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8528 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8529 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8531 case ESSENCE_SH_COLD:
8532 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8537 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8538 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8540 case ESSENCE_RESISTANCE:
8541 case ESSENCE_SUSTAIN:
8542 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))
8547 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8548 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8549 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8550 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8555 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8558 if (es_ptr->add == ESSENCE_SUSTAIN)
8560 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8561 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8562 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8563 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8567 o_ptr->xtra3 = es_ptr->add + 1;
8571 p_ptr->energy_use = 100;
8574 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8576 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8579 /* Combine the pack */
8580 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8583 p_ptr->window |= (PW_INVEN);
8590 static void erase_essence(void)
8595 char o_name[MAX_NLEN];
8596 BIT_FLAGS flgs[TR_FLAG_SIZE];
8598 item_tester_hook = object_is_smith;
8601 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8602 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8604 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8606 /* Get the item (in the pack) */
8609 o_ptr = &inventory[item];
8612 /* Get the item (on the floor) */
8615 o_ptr = &o_list[0 - item];
8618 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8619 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8621 p_ptr->energy_use = 100;
8623 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8625 o_ptr->to_h -= (o_ptr->xtra4>>8);
8626 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8628 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8629 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8632 object_flags(o_ptr, flgs);
8633 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8634 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8636 /* Combine the pack */
8637 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8640 p_ptr->window |= (PW_INVEN);
8644 * @brief 鍛冶コマンドのメインルーチン
8645 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8648 void do_cmd_kaji(bool only_browse)
8653 int menu_line = (use_menu ? 1 : 0);
8657 if (p_ptr->confused)
8659 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8664 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8669 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8675 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8677 #endif /* ALLOW_REPEAT */
8679 if (only_browse) screen_save();
8681 if (!only_browse) screen_save();
8687 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8688 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8689 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8690 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8691 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8692 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8694 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8695 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8696 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8697 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8698 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8699 prt(format("Choose command from menu."), 0, 0);
8726 if (menu_line > 5) menu_line -= 5;
8735 prt(" a) エッセンス一覧", 2, 14);
8736 prt(" b) エッセンス抽出", 3, 14);
8737 prt(" c) エッセンス消去", 4, 14);
8738 prt(" d) エッセンス付加", 5, 14);
8739 prt(" e) 武器/防具強化", 6, 14);
8740 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8742 prt(" a) List essences", 2, 14);
8743 prt(" b) Extract essence", 3, 14);
8744 prt(" c) Remove essence", 4, 14);
8745 prt(" d) Add essence", 5, 14);
8746 prt(" e) Enchant weapon/armor", 6, 14);
8747 if (!get_com("Command :", &choice, TRUE))
8784 /* Clear lines, position cursor (really should use strlen here) */
8785 Term_erase(14, 21, 255);
8786 Term_erase(14, 20, 255);
8787 Term_erase(14, 19, 255);
8788 Term_erase(14, 18, 255);
8789 Term_erase(14, 17, 255);
8790 Term_erase(14, 16, 255);
8792 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8793 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8795 prt(&temp[j], line, 15);
8800 if (!only_browse) screen_load();
8801 } while (only_browse);
8805 #endif /* ALLOW_REPEAT */
8809 case 1: display_essence();break;
8810 case 2: drain_essence();break;
8811 case 3: erase_essence();break;
8813 mode = choose_essence();
8818 case 5: add_essence(10);break;
8824 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8825 * Torches have special abilities when they are flaming.
8826 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8827 * @param flgs 特別に追加するフラグを返す参照ポインタ
8830 void torch_flags(object_type *o_ptr, u32b *flgs)
8832 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8834 if (o_ptr->xtra4 > 0)
8836 add_flag(flgs, TR_BRAND_FIRE);
8837 add_flag(flgs, TR_KILL_UNDEAD);
8838 add_flag(flgs, TR_THROW);
8844 * @brief 投擲時たいまつにダイスを与える。
8845 * Torches have special abilities when they are flaming.
8846 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8847 * @param dd 特別なダイス数を返す参照ポインタ
8848 * @param ds 特別なダイス面数を返す参照ポインタ
8851 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8853 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8855 if (o_ptr->xtra4 > 0)
8864 * @brief 投擲時命中したたいまつの寿命を縮める。
8865 * Torches have special abilities when they are flaming.
8866 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8869 void torch_lost_fuel(object_type *o_ptr)
8871 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8873 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8874 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;