3 * @brief オブジェクトの実装 / Object code, part 2
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
8 * This software may be copied and distributed for educational, research,\n
9 * and not for profit purposes provided that this copyright and statement\n
10 * are included in all such copies. Other copyrights may also apply.\n
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 #include "object-hook.h"
17 static void one_sustain(object_type *o_ptr);
20 static cptr const kaji_tips[5] =
23 "現在持っているエッセンスの一覧を表示する。",
24 "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
25 "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
26 "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
27 "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
29 "Display essences you have.",
30 "Extract essences from an item. The item become non magical.",
31 "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
32 "Add essences to an item. The improved items or artifacts cannot be reimprove.",
33 "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
38 * @brief 対象のオブジェクトにランダムな能力維持を一つ付加する。/ Choose one random sustain
40 * @param o_ptr 対象のオブジェクト構造体ポインタ
43 static void one_sustain(object_type *o_ptr)
47 case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
48 case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
49 case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
50 case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
51 case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
52 case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
57 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
58 * @param o_idx 削除対象のオブジェクト構造体ポインタ
61 void excise_object_idx(int o_idx)
65 s16b this_o_idx, next_o_idx = 0;
71 j_ptr = &o_list[o_idx];
74 if (j_ptr->held_m_idx)
79 m_ptr = &m_list[j_ptr->held_m_idx];
81 /* Scan all objects in the grid */
82 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
87 o_ptr = &o_list[this_o_idx];
89 /* Acquire next object */
90 next_o_idx = o_ptr->next_o_idx;
93 if (this_o_idx == o_idx)
98 /* Remove from list */
99 m_ptr->hold_o_idx = next_o_idx;
107 /* Previous object */
108 k_ptr = &o_list[prev_o_idx];
110 /* Remove from list */
111 k_ptr->next_o_idx = next_o_idx;
114 /* Forget next pointer */
115 o_ptr->next_o_idx = 0;
121 /* Save prev_o_idx */
122 prev_o_idx = this_o_idx;
137 /* Scan all objects in the grid */
138 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
143 o_ptr = &o_list[this_o_idx];
145 /* Acquire next object */
146 next_o_idx = o_ptr->next_o_idx;
149 if (this_o_idx == o_idx)
154 /* Remove from list */
155 c_ptr->o_idx = next_o_idx;
163 /* Previous object */
164 k_ptr = &o_list[prev_o_idx];
166 /* Remove from list */
167 k_ptr->next_o_idx = next_o_idx;
170 /* Forget next pointer */
171 o_ptr->next_o_idx = 0;
177 /* Save prev_o_idx */
178 prev_o_idx = this_o_idx;
184 * @brief オブジェクトを削除する /
185 * Delete a dungeon object
186 * @param o_idx 削除対象のオブジェクト構造体ポインタ
189 * Handle "stacks" of objects correctly.
191 void delete_object_idx(int o_idx)
196 excise_object_idx(o_idx);
199 j_ptr = &o_list[o_idx];
202 if (!(j_ptr->held_m_idx))
214 /* Wipe the object */
223 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
224 * Delete a dungeon object
225 * @param y 削除したフロアマスのY座標
226 * @param x 削除したフロアマスのX座標
229 void delete_object(int y, int x)
233 s16b this_o_idx, next_o_idx = 0;
236 /* Refuse "illegal" locations */
237 if (!in_bounds(y, x)) return;
243 /* Scan all objects in the grid */
244 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
249 o_ptr = &o_list[this_o_idx];
251 /* Acquire next object */
252 next_o_idx = o_ptr->next_o_idx;
254 /* Wipe the object */
261 /* Objects are gone */
270 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
271 * Move an object from index i1 to index i2 in the object list
272 * @param i1 整理したい配列の始点
273 * @param i2 整理したい配列の終点
276 static void compact_objects_aux(IDX i1, IDX i2)
283 if (i1 == i2) return;
287 for (i = 1; i < o_max; i++)
292 /* Skip "dead" objects */
293 if (!o_ptr->k_idx) continue;
295 /* Repair "next" pointers */
296 if (o_ptr->next_o_idx == i1)
299 o_ptr->next_o_idx = i2;
309 if (o_ptr->held_m_idx)
313 /* Acquire monster */
314 m_ptr = &m_list[o_ptr->held_m_idx];
317 if (m_ptr->hold_o_idx == i1)
320 m_ptr->hold_o_idx = i2;
329 /* Acquire location */
337 if (c_ptr->o_idx == i1)
346 o_list[i2] = o_list[i1];
354 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
355 * Compact and Reorder the object list.
356 * @param size 最低でも減らしたいオブジェクト数の水準
360 * This function can be very dangerous, use with caution!\n
362 * When actually "compacting" objects, we base the saving throw on a\n
363 * combination of object level, distance from player, and current\n
366 * After "compacting" (if needed), we "reorder" the objects into a more\n
367 * compact order, and we reset the allocation info, and the "live" array.\n
369 void compact_objects(int size)
373 int cur_lev, cur_dis, chance;
381 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
384 p_ptr->redraw |= (PR_MAP);
387 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
391 /* Compact at least 'size' objects */
392 for (num = 0, cnt = 1; num < size; cnt++)
394 /* Get more vicious each iteration */
397 /* Get closer each iteration */
398 cur_dis = 5 * (20 - cnt);
400 /* Examine the objects */
401 for (i = 1; i < o_max; i++)
405 /* Skip dead objects */
406 if (!o_ptr->k_idx) continue;
408 /* Hack -- High level objects start out "immune" */
409 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
412 if (o_ptr->held_m_idx)
416 /* Acquire monster */
417 m_ptr = &m_list[o_ptr->held_m_idx];
419 /* Get the location */
423 /* Monsters protect their objects */
424 if (randint0(100) < 90) continue;
430 /* Get the location */
435 /* Nearby objects start out "immune" */
436 if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
441 /* Hack -- only compact artifacts in emergencies */
442 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
443 (cnt < 1000)) chance = 100;
445 /* Apply the saving throw */
446 if (randint0(100) < chance) continue;
448 /* Delete the object */
449 delete_object_idx(i);
457 /* Excise dead objects (backwards!) */
458 for (i = o_max - 1; i >= 1; i--)
462 /* Skip real objects */
463 if (o_ptr->k_idx) continue;
465 /* Move last object into open hole */
466 compact_objects_aux(o_max - 1, i);
468 /* Compress "o_max" */
475 * @brief グローバルオブジェクト配列を初期化する /
476 * Delete all the items when player leaves the level
477 * @note we do NOT visually reflect these (irrelevant) changes
479 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
480 * and the "m_ptr->next_o_idx" field for every monster, since
481 * we know we are clearing every object. Technically, we only
482 * clear those fields for grids/monsters containing objects,
483 * and we clear it once for every such object.
486 void wipe_o_list(void)
490 /* Delete the existing objects */
491 for (i = 1; i < o_max; i++)
493 object_type *o_ptr = &o_list[i];
495 /* Skip dead objects */
496 if (!o_ptr->k_idx) continue;
498 /* Mega-Hack -- preserve artifacts */
499 if (!character_dungeon || preserve_mode)
501 /* Hack -- Preserve unknown artifacts */
502 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
504 /* Mega-Hack -- Preserve the artifact */
505 a_info[o_ptr->name1].cur_num = 0;
510 if (o_ptr->held_m_idx)
515 m_ptr = &m_list[o_ptr->held_m_idx];
517 /* Hack -- see above */
518 m_ptr->hold_o_idx = 0;
526 /* Access location */
533 /* Hack -- see above */
537 /* Wipe the object */
550 * @brief グローバルオブジェクト配列から空きを取得する /
551 * Acquires and returns the index of a "free" object.
552 * @return 開いているオブジェクト要素のID
554 * This routine should almost never fail, but in case it does,
555 * we must be sure to handle "failure" of this routine.
562 /* Initial allocation */
563 if (o_max < max_o_idx)
568 /* Expand object array */
574 /* Use this object */
579 /* Recycle dead objects */
580 for (i = 1; i < o_max; i++)
587 /* Skip live objects */
588 if (o_ptr->k_idx) continue;
593 /* Use this object */
598 /* Warn the player (except during dungeon creation) */
599 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
607 * @brief オブジェクト生成テーブルに生成制約を加える /
608 * Apply a "object restriction function" to the "object allocation table"
610 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
612 static errr get_obj_num_prep(void)
617 alloc_entry *table = alloc_kind_table;
619 /* Scan the allocation table */
620 for (i = 0; i < alloc_kind_size; i++)
622 /* Accept objects which pass the restriction, if any */
623 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
625 /* Accept this object */
626 table[i].prob2 = table[i].prob1;
629 /* Do not use this object */
632 /* Decline this object */
643 * @brief オブジェクト生成テーブルからアイテムを取得する /
644 * Choose an object kind that seems "appropriate" to the given level
646 * @return 選ばれたオブジェクトベースID
648 * This function uses the "prob2" field of the "object allocation table",\n
649 * and various local information, to calculate the "prob3" field of the\n
650 * same table, which is then used to choose an "appropriate" object, in\n
651 * a relatively efficient manner.\n
653 * It is (slightly) more likely to acquire an object of the given level\n
654 * than one of a lower level. This is done by choosing several objects\n
655 * appropriate to the given level and keeping the "hardest" one.\n
657 * Note that if no objects are "appropriate", then this function will\n
658 * fail, and return zero, but this should *almost* never happen.\n
660 s16b get_obj_num(int level)
666 alloc_entry *table = alloc_kind_table;
668 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
671 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
673 /* Occasional "boost" */
674 if (one_in_(GREAT_OBJ))
676 /* What a bizarre calculation */
677 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
684 /* Process probabilities */
685 for (i = 0; i < alloc_kind_size; i++)
687 /* Objects are sorted by depth */
688 if (table[i].level > level) break;
693 /* Access the index */
694 k_idx = table[i].index;
696 /* Access the actual kind */
697 k_ptr = &k_info[k_idx];
699 /* Hack -- prevent embedded chests */
700 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
703 table[i].prob3 = table[i].prob2;
706 total += table[i].prob3;
709 /* No legal objects */
710 if (total <= 0) return (0);
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;
730 /* Try for a "better" object once (50%) or 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;
753 /* Try for a "better" object twice (10%) */
760 value = randint0(total);
762 /* Find the object */
763 for (i = 0; i < alloc_kind_size; i++)
765 /* Found the entry */
766 if (value < table[i].prob3) break;
769 value = value - table[i].prob3;
772 /* Keep the "best" one */
773 if (table[i].level < table[j].level) i = j;
778 return (table[i].index);
783 * @brief オブジェクトを鑑定済にする /
784 * Known is true when the "attributes" of an object are "known".
785 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
787 * These include tohit, todam, toac, cost, and pval (charges).\n
789 * Note that "knowing" an object gives you everything that an "awareness"\n
790 * gives you, and much more. In fact, the player is always "aware" of any\n
791 * item of which he has full "knowledge".\n
793 * But having full knowledge of, say, one "wand of wonder", does not, by\n
794 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
795 * It happens that most "identify" routines (including "buying from a shop")\n
796 * will make the player "aware" of the object as well as fully "know" it.\n
798 * This routine also removes any inscriptions generated by "feelings".\n
800 void object_known(object_type *o_ptr)
802 /* Remove "default inscriptions" */
803 o_ptr->feeling = FEEL_NONE;
805 /* Clear the "Felt" info */
806 o_ptr->ident &= ~(IDENT_SENSE);
808 /* Clear the "Empty" info */
809 o_ptr->ident &= ~(IDENT_EMPTY);
811 /* Now we know about the item */
812 o_ptr->ident |= (IDENT_KNOWN);
816 * @brief オブジェクトを*鑑定*済にする /
817 * The player is now aware of the effects of the given object.
818 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
821 void object_aware(object_type *o_ptr)
823 bool mihanmei = !object_is_aware(o_ptr);
825 /* Fully aware of the effects */
826 k_info[o_ptr->k_idx].aware = TRUE;
828 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
829 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
833 char o_name[MAX_NLEN];
836 object_copy(q_ptr, o_ptr);
839 object_desc(o_name, q_ptr, OD_NAME_ONLY);
841 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
847 * @brief オブジェクトを試行済にする /
848 * Something has been "sampled"
849 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
852 void object_tried(object_type *o_ptr)
854 /* Mark it as tried (even if "aware") */
855 k_info[o_ptr->k_idx].tried = TRUE;
860 * @brief 未鑑定なベースアイテムの基本価格を返す /
861 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
862 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
863 * @return オブジェクトの未鑑定価格
865 static s32b object_value_base(object_type *o_ptr)
867 /* Aware item -- use template cost */
868 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
870 /* Analyze the type */
875 case TV_FOOD: return (5L);
877 /* Un-aware Potions */
878 case TV_POTION: return (20L);
880 /* Un-aware Scrolls */
881 case TV_SCROLL: return (20L);
883 /* Un-aware Staffs */
884 case TV_STAFF: return (70L);
887 case TV_WAND: return (50L);
890 case TV_ROD: return (90L);
893 case TV_RING: return (45L);
895 /* Un-aware Amulets */
896 case TV_AMULET: return (45L);
898 /* Figurines, relative to monster level */
901 int level = r_info[o_ptr->pval].level;
902 if (level < 20) return level*50L;
903 else if (level < 30) return 1000+(level-20)*150L;
904 else if (level < 40) return 2500+(level-30)*350L;
905 else if (level < 50) return 6000+(level-40)*800L;
906 else return 14000+(level-50)*2000L;
910 if (!o_ptr->pval) return 1000L;
911 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
914 /* Paranoia -- Oops */
920 * @brief オブジェクトのフラグ類から価格を算出する /
921 * Return the value of the flags the object has...
922 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
923 * @param plusses フラグに与える価格の基本重み
924 * @return オブジェクトのフラグ価格
926 s32b flag_cost(object_type *o_ptr, int plusses)
929 u32b flgs[TR_FLAG_SIZE];
933 object_kind *k_ptr = &k_info[o_ptr->k_idx];
935 object_flags(o_ptr, flgs);
938 * Exclude fixed flags of the base item.
939 * pval bonuses of base item will be treated later.
941 for (i = 0; i < TR_FLAG_SIZE; i++)
942 flgs[i] &= ~(k_ptr->flags[i]);
944 /* Exclude fixed flags of the fixed artifact. */
945 if (object_is_fixed_artifact(o_ptr))
947 artifact_type *a_ptr = &a_info[o_ptr->name1];
949 for (i = 0; i < TR_FLAG_SIZE; i++)
950 flgs[i] &= ~(a_ptr->flags[i]);
953 /* Exclude fixed flags of the ego-item. */
954 else if (object_is_ego(o_ptr))
956 ego_item_type *e_ptr = &e_info[o_ptr->name2];
958 for (i = 0; i < TR_FLAG_SIZE; i++)
959 flgs[i] &= ~(e_ptr->flags[i]);
964 * Calucurate values of remaining flags
966 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
967 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
968 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
969 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
970 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
971 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
972 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
973 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
974 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
975 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
976 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
977 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
978 total += (10000 + (2500 * plusses));
979 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
980 total += (10000 + (2500 * plusses));
984 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
985 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
986 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
987 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
988 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
989 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
990 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
991 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
992 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
993 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
994 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
995 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
996 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
997 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
998 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
999 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
1000 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
1001 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
1002 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
1003 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
1004 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
1006 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
1007 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
1008 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
1009 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
1010 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
1011 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
1012 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
1013 total += (tmp_cost * count);
1015 if (have_flag(flgs, TR_SUST_STR)) total += 850;
1016 if (have_flag(flgs, TR_SUST_INT)) total += 850;
1017 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
1018 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
1019 if (have_flag(flgs, TR_SUST_CON)) total += 850;
1020 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
1021 if (have_flag(flgs, TR_RIDING)) total += 0;
1022 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
1023 if (have_flag(flgs, TR_THROW)) total += 5000;
1024 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
1025 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
1029 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
1030 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
1031 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
1032 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
1033 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
1034 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
1035 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1036 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1037 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1038 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1039 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1040 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1041 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1042 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1043 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1044 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1045 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1046 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1047 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1048 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1049 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1050 total += (tmp_cost * count);
1052 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1053 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1054 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1055 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1056 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1057 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1058 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1059 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1060 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1061 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1062 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1063 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1064 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1065 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1066 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1067 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1068 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1069 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1070 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1071 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1072 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1073 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1074 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1075 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1076 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1077 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1078 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1079 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1080 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1081 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1082 if (have_flag(flgs, TR_REGEN)) total += 2500;
1083 if (have_flag(flgs, TR_WARNING)) total += 2000;
1084 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1085 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1086 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1087 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1088 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1089 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1090 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1091 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1092 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1093 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1094 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1095 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1096 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1097 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1098 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1099 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1100 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1101 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1102 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1103 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1104 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1105 if (have_flag(flgs, TR_TELEPORT))
1107 if (object_is_cursed(o_ptr))
1112 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1113 if (have_flag(flgs, TR_BLESSED)) total += 750;
1114 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1115 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1116 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1117 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1118 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1120 /* Also, give some extra for activatable powers... */
1121 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1123 const activation_type* const act_ptr = find_activation_info(o_ptr);
1125 total += act_ptr->value;
1134 * @brief オブジェクトの真の価格を算出する /
1135 * Return the value of the flags the object has...
1136 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1137 * @return オブジェクトの本価格
1139 * Return the "real" price of a "known" item, not including discounts\n
1141 * Wand and staffs get cost for each charge\n
1143 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1145 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1147 * Missiles are only worth 5 gold per bonus point, since they\n
1148 * usually appear in groups of 20, and we want the player to get\n
1149 * the same amount of cash for any "equivalent" item. Note that\n
1150 * missiles never have any of the "pval" flags, and in fact, they\n
1151 * only have a few of the available flags, primarily of the "slay"\n
1152 * and "brand" and "ignore" variety.\n
1154 * Armor with a negative armor bonus is worthless.\n
1155 * Weapons with negative hit+damage bonuses are worthless.\n
1157 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1159 s32b object_value_real(object_type *o_ptr)
1163 u32b flgs[TR_FLAG_SIZE];
1165 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1168 /* Hack -- "worthless" items */
1169 if (!k_info[o_ptr->k_idx].cost) return (0L);
1172 value = k_info[o_ptr->k_idx].cost;
1174 /* Extract some flags */
1175 object_flags(o_ptr, flgs);
1178 if (object_is_fixed_artifact(o_ptr))
1180 artifact_type *a_ptr = &a_info[o_ptr->name1];
1182 /* Hack -- "worthless" artifacts */
1183 if (!a_ptr->cost) return (0L);
1185 /* Hack -- Use the artifact cost instead */
1186 value = a_ptr->cost;
1187 value += flag_cost(o_ptr, o_ptr->pval);
1189 /* Don't add pval bonuses etc. */
1194 else if (object_is_ego(o_ptr))
1196 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1198 /* Hack -- "worthless" ego-items */
1199 if (!e_ptr->cost) return (0L);
1201 /* Hack -- Reward the ego-item with a bonus */
1202 value += e_ptr->cost;
1203 value += flag_cost(o_ptr, o_ptr->pval);
1211 for (i = 0; i < TR_FLAG_SIZE; i++)
1212 if (o_ptr->art_flags[i]) flag = TRUE;
1214 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1217 /* Analyze pval bonus for normal object */
1218 switch (o_ptr->tval)
1241 if (!o_ptr->pval) break;
1243 /* Hack -- Negative "pval" is always bad */
1244 if (o_ptr->pval < 0) return (0L);
1246 /* Give credit for stat bonuses */
1247 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1248 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1249 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1250 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1251 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1252 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1254 /* Give credit for stealth and searching */
1255 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1256 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1257 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1259 /* Give credit for infra-vision and tunneling */
1260 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1261 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1263 /* Give credit for extra attacks */
1264 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1266 /* Give credit for speed bonus */
1267 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1273 /* Analyze the item */
1274 switch (o_ptr->tval)
1279 /* Pay extra for charges, depending on standard number of
1280 * charges. Handle new-style wands correctly. -LM-
1282 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1289 /* Pay extra for charges, depending on standard number of
1292 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1302 /* Hack -- negative bonuses are bad */
1303 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1305 /* Give credit for bonuses */
1306 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1323 /* Hack -- negative armor bonus */
1324 if (o_ptr->to_a < 0) return (0L);
1326 /* Give credit for bonuses */
1327 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1340 /* Hack -- negative hit/damage bonuses */
1341 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1343 /* Factor in the bonuses */
1344 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1346 /* Hack -- Factor in extra damage dice and sides */
1347 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1348 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1359 /* Hack -- negative hit/damage bonuses */
1360 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1362 /* Factor in the bonuses */
1363 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1365 /* Hack -- Factor in extra damage dice and sides */
1366 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1367 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1373 /* Figurines, relative to monster level */
1376 int level = r_info[o_ptr->pval].level;
1377 if (level < 20) value = level*50L;
1378 else if (level < 30) value = 1000+(level-20)*150L;
1379 else if (level < 40) value = 2500+(level-30)*350L;
1380 else if (level < 50) value = 6000+(level-40)*800L;
1381 else value = 14000+(level-50)*2000L;
1387 if (!o_ptr->pval) value = 1000L;
1388 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1394 if (!o_ptr->pval) value = 0L;
1399 /* Worthless object */
1400 if (value < 0) return 0L;
1402 /* Return the value */
1408 * @brief オブジェクト価格算出のメインルーチン /
1409 * Return the price of an item including plusses (and charges)
1410 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1411 * @return オブジェクトの判明している現価格
1413 * This function returns the "value" of the given item (qty one)\n
1415 * Never notice "unknown" bonuses or properties, including "curses",\n
1416 * since that would give the player information he did not have.\n
1418 * Note that discounted items stay discounted forever, even if\n
1419 * the discount is "forgotten" by the player via memory loss.\n
1421 s32b object_value(object_type *o_ptr)
1426 /* Unknown items -- acquire a base value */
1427 if (object_is_known(o_ptr))
1429 /* Broken items -- worthless */
1430 if (object_is_broken(o_ptr)) return (0L);
1432 /* Cursed items -- worthless */
1433 if (object_is_cursed(o_ptr)) return (0L);
1435 /* Real value (see above) */
1436 value = object_value_real(o_ptr);
1439 /* Known items -- acquire the actual value */
1442 /* Hack -- Felt broken items */
1443 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1445 /* Hack -- Felt cursed items */
1446 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1448 /* Base value (see above) */
1449 value = object_value_base(o_ptr);
1453 /* Apply discount (if any) */
1454 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1457 /* Return the final value */
1464 * @brief 破壊可能なアイテムかを返す /
1465 * Determines whether an object can be destroyed, and makes fake inscription.
1466 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1467 * @return オブジェクトが破壊可能ならばTRUEを返す
1469 bool can_player_destroy_object(object_type *o_ptr)
1471 /* Artifacts cannot be destroyed */
1472 if (!object_is_artifact(o_ptr)) return TRUE;
1474 /* If object is unidentified, makes fake inscription */
1475 if (!object_is_known(o_ptr))
1477 byte feel = FEEL_SPECIAL;
1479 /* Hack -- Handle icky artifacts */
1480 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1482 /* Hack -- inscribe the artifact */
1483 o_ptr->feeling = feel;
1485 /* We have "felt" it (again) */
1486 o_ptr->ident |= (IDENT_SENSE);
1488 /* Combine the pack */
1489 p_ptr->notice |= (PN_COMBINE);
1492 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1498 /* Identified artifact -- Nothing to do */
1504 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1505 * Distribute charges of rods or wands.
1506 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1507 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1508 * @param amt 分割したい回数量 number of items that are transfered
1511 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1512 * charges need to be allocated between the two stacks. If all the items\n
1513 * are being dropped, it makes for a neater message to leave the original\n
1514 * stack's pval alone. -LM-\n
1516 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1518 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1520 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1521 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1523 /* Hack -- Rods also need to have their timeouts distributed. The
1524 * dropped stack will accept all time remaining to charge up to its
1527 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1529 if (q_ptr->pval > o_ptr->timeout)
1530 q_ptr->timeout = o_ptr->timeout;
1532 q_ptr->timeout = q_ptr->pval;
1534 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1540 * @brief 魔法棒やロッドの使用回数を減らす /
1541 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1542 * @param amt 減らしたい回数量 number of items that are transfered
1545 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1546 * charges of the stack needs to be reduced, unless all the items are\n
1547 * being destroyed. -LM-\n
1549 void reduce_charges(object_type *o_ptr, int amt)
1551 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1552 (amt < o_ptr->number))
1554 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1559 * Determine if an item can "absorb" a second item
1561 * See "object_absorb()" for the actual "absorption" code.
1563 * If permitted, we allow staffs (if they are known to have equal charges
1564 * and both are either known or confirmed empty) and wands (if both are
1565 * either known or confirmed empty) and rods (in all cases) to combine.
1566 * Staffs will unstack (if necessary) when they are used, but wands and
1567 * rods will only unstack if one is dropped. -LM-
1569 * If permitted, we allow weapons/armor to stack, if fully "known".
1571 * Missiles will combine if both stacks have the same "known" status.
1572 * This is done to make unidentified stacks of missiles useful.
1574 * Food, potions, scrolls, and "easy know" items always stack.
1576 * Chests, and activatable items, never stack (for various reasons).
1580 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1582 #define MAX_STACK_SIZE 99
1586 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1587 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1588 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1589 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1590 * @return 重ね合わせ可能なアイテム数
1592 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1596 /* Default maximum number of stack */
1597 int max_num = MAX_STACK_SIZE;
1599 /* Require identical object types */
1600 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1603 /* Analyze the items */
1604 switch (o_ptr->tval)
1606 /* Chests and Statues*/
1617 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1618 if (o_ptr->pval != j_ptr->pval) return 0;
1622 /* Figurines and Corpses*/
1627 if (o_ptr->pval != j_ptr->pval) return 0;
1633 /* Food and Potions and Scrolls */
1645 /* Require either knowledge or known empty for both staffs. */
1646 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1647 !object_is_known(o_ptr)) ||
1648 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1649 !object_is_known(j_ptr))) return 0;
1651 /* Require identical charges, since staffs are bulky. */
1652 if (o_ptr->pval != j_ptr->pval) return 0;
1661 /* Require either knowledge or known empty for both wands. */
1662 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1663 !object_is_known(o_ptr)) ||
1664 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1665 !object_is_known(j_ptr))) return 0;
1667 /* Wand charges combine in O&ZAngband. */
1673 /* Staffs and Wands and Rods */
1676 /* Prevent overflaw of timeout */
1677 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1683 /* Weapons and Armor */
1699 /* Rings, Amulets, Lites */
1705 /* Require full knowledge of both items */
1706 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1716 /* Require identical knowledge of both items */
1717 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1718 if (o_ptr->feeling != j_ptr->feeling) return 0;
1720 /* Require identical "bonuses" */
1721 if (o_ptr->to_h != j_ptr->to_h) return 0;
1722 if (o_ptr->to_d != j_ptr->to_d) return 0;
1723 if (o_ptr->to_a != j_ptr->to_a) return 0;
1725 /* Require identical "pval" code */
1726 if (o_ptr->pval != j_ptr->pval) return 0;
1728 /* Artifacts never stack */
1729 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1731 /* Require identical "ego-item" names */
1732 if (o_ptr->name2 != j_ptr->name2) return 0;
1734 /* Require identical added essence */
1735 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1736 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1738 /* Hack -- Never stack "powerful" items */
1739 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1741 /* Hack -- Never stack recharging items */
1742 if (o_ptr->timeout || j_ptr->timeout) return 0;
1744 /* Require identical "values" */
1745 if (o_ptr->ac != j_ptr->ac) return 0;
1746 if (o_ptr->dd != j_ptr->dd) return 0;
1747 if (o_ptr->ds != j_ptr->ds) return 0;
1756 /* Require knowledge */
1757 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1765 /* Hack -- Identical art_flags! */
1766 for (i = 0; i < TR_FLAG_SIZE; i++)
1767 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1769 /* Hack -- Require identical "cursed" status */
1770 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1772 /* Hack -- Require identical "broken" status */
1773 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1776 /* Hack -- require semi-matching "inscriptions" */
1777 if (o_ptr->inscription && j_ptr->inscription &&
1778 (o_ptr->inscription != j_ptr->inscription))
1781 /* Hack -- normally require matching "inscriptions" */
1782 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1784 /* Hack -- normally require matching "discounts" */
1785 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1788 /* They match, so they must be similar */
1793 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1794 * Determine if an item can absorb a second item.
1795 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1796 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1797 * @return 重ね合わせ可能ならばTRUEを返す。
1799 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1801 int total = o_ptr->number + j_ptr->number;
1804 /* Are these objects similar? */
1805 max_num = object_similar_part(o_ptr, j_ptr);
1807 /* Return if not similar */
1808 if (!max_num) return FALSE;
1810 /* Maximal "stacking" limit */
1811 if (total > max_num) return (0);
1814 /* They match, so they must be similar */
1820 * @brief 両オブジェクトをスロットに重ね合わせる。
1821 * Allow one item to "absorb" another, assuming they are similar
1822 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1823 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1826 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1828 int max_num = object_similar_part(o_ptr, j_ptr);
1829 int total = o_ptr->number + j_ptr->number;
1830 int diff = (total > max_num) ? total - max_num : 0;
1832 /* Combine quantity, lose excess items */
1833 o_ptr->number = (total > max_num) ? max_num : total;
1835 /* Hack -- blend "known" status */
1836 if (object_is_known(j_ptr)) object_known(o_ptr);
1838 /* Hack -- clear "storebought" if only one has it */
1839 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1840 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1842 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1843 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1846 /* Hack -- blend "mental" status */
1847 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1849 /* Hack -- blend "inscriptions" */
1850 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1852 /* Hack -- blend "feelings" */
1853 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1855 /* Hack -- could average discounts XXX XXX XXX */
1856 /* Hack -- save largest discount XXX XXX XXX */
1857 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1859 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1860 if (o_ptr->tval == TV_ROD)
1862 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1863 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1866 /* Hack -- if wands are stacking, combine the charges. -LM- */
1867 if (o_ptr->tval == TV_WAND)
1869 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1875 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1876 * Find the index of the object_kind with the given tval and sval
1877 * @param tval 検索したいベースアイテムのtval
1878 * @param sval 検索したいベースアイテムのsval
1881 IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
1888 for (k = 1; k < max_k_idx; k++)
1890 object_kind *k_ptr = &k_info[k];
1892 /* Require correct tval */
1893 if (k_ptr->tval != tval) continue;
1896 if (k_ptr->sval == sval) return (k);
1898 /* Ignore illegal items */
1899 if (sval != SV_ANY) continue;
1901 /* Apply the randomizer */
1902 if (!one_in_(++num)) continue;
1904 /* Use this value */
1908 /* Return this choice */
1916 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1926 * @brief オブジェクトを初期化する
1927 * Wipe an object clean.
1928 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1931 void object_wipe(object_type *o_ptr)
1933 /* Wipe the structure */
1934 (void)WIPE(o_ptr, object_type);
1939 * @brief オブジェクトを複製する
1940 * Wipe an object clean.
1941 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1942 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1945 void object_copy(object_type *o_ptr, object_type *j_ptr)
1947 /* Copy the structure */
1948 (void)COPY(o_ptr, j_ptr, object_type);
1953 * @brief オブジェクト構造体にベースアイテムを作成する
1954 * Prepare an object based on an object kind.
1955 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1956 * @param k_idx 新たに作成したいベースアイテム情報のID
1959 void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
1961 object_kind *k_ptr = &k_info[k_idx];
1963 /* Clear the record */
1966 /* Save the kind index */
1967 o_ptr->k_idx = k_idx;
1969 /* Efficiency -- tval/sval */
1970 o_ptr->tval = k_ptr->tval;
1971 o_ptr->sval = k_ptr->sval;
1973 /* Default "pval" */
1974 o_ptr->pval = k_ptr->pval;
1976 /* Default number */
1979 /* Default weight */
1980 o_ptr->weight = k_ptr->weight;
1983 o_ptr->to_h = k_ptr->to_h;
1984 o_ptr->to_d = k_ptr->to_d;
1985 o_ptr->to_a = k_ptr->to_a;
1988 o_ptr->ac = k_ptr->ac;
1989 o_ptr->dd = k_ptr->dd;
1990 o_ptr->ds = k_ptr->ds;
1992 /* Default activation */
1993 if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx;
1995 /* Hack -- worthless items are always "broken" */
1996 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1998 /* Hack -- cursed items are always "cursed" */
1999 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
2000 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2001 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
2002 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
2003 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
2004 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
2009 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
2010 * Help determine an "enchantment bonus" for an object.
2011 * @param max ボーナス値の限度
2012 * @param level ボーナス値に加味する基準生成階
2013 * @return 算出されたボーナス値
2015 * To avoid floating point but still provide a smooth distribution of bonuses,\n
2016 * we simply round the results of division in such a way as to "average" the\n
2017 * correct floating point value.\n
2019 * This function has been changed. It uses "randnor()" to choose values from\n
2020 * a normal distribution, whose mean moves from zero towards the max as the\n
2021 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
2022 * and whose values are forced to lie between zero and the max, inclusive.\n
2024 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
2025 * rare to get the "full" enchantment on an object, even a deep levels.\n
2027 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
2029 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
2031 * N 0 1 2 3 4 5 6 7 8 9 10\n
2032 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
2033 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
2034 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
2035 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2036 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2037 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2038 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2039 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2040 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2041 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2042 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2043 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2044 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2045 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2046 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2047 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2048 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2049 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2051 int m_bonus(int max, DEPTH level)
2053 int bonus, stand, extra, value;
2056 /* Paranoia -- enforce maximal "level" */
2057 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2060 /* The "bonus" moves towards the max */
2061 bonus = ((max * level) / MAX_DEPTH);
2063 /* Hack -- determine fraction of error */
2064 extra = ((max * level) % MAX_DEPTH);
2066 /* Hack -- simulate floating point computations */
2067 if (randint0(MAX_DEPTH) < extra) bonus++;
2070 /* The "stand" is equal to one quarter of the max */
2073 /* Hack -- determine fraction of error */
2076 /* Hack -- simulate floating point computations */
2077 if (randint0(4) < extra) stand++;
2080 /* Choose an "interesting" value */
2081 value = randnor(bonus, stand);
2083 /* Enforce the minimum value */
2084 if (value < 0) return (0);
2086 /* Enforce the maximum value */
2087 if (value > max) return (max);
2095 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2096 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2099 static void object_mention(object_type *o_ptr)
2101 char o_name[MAX_NLEN];
2103 object_aware(o_ptr);
2104 object_known(o_ptr);
2106 /* Mark the item as fully known */
2107 o_ptr->ident |= (IDENT_MENTAL);
2110 object_desc(o_name, o_ptr, 0);
2111 msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
2115 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2116 * Mega-Hack -- Attempt to create one of the "Special Objects"
2117 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2118 * @return 生成に成功したらTRUEを返す。
2120 * We are only called from "make_object()", and we assume that\n
2121 * "apply_magic()" is called immediately after we return.\n
2123 * Note -- see "make_artifact()" and "apply_magic()"\n
2125 static bool make_artifact_special(object_type *o_ptr)
2130 /*! @note 地上ではキャンセルする / No artifacts in the town */
2131 if (!dun_level) return (FALSE);
2133 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2134 if (get_obj_num_hook) return (FALSE);
2136 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2137 for (i = 0; i < max_a_idx; i++)
2139 artifact_type *a_ptr = &a_info[i];
2141 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2142 if (!a_ptr->name) continue;
2144 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2145 if (a_ptr->cur_num) continue;
2146 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2147 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2149 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2150 * XXX XXX Enforce minimum "depth" (loosely) */
2151 if (a_ptr->level > object_level)
2153 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2154 int d = (a_ptr->level - object_level) * 2;
2155 if (!one_in_(d)) continue;
2158 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2159 if (!one_in_(a_ptr->rarity)) continue;
2161 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2162 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2163 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2164 if (k_info[k_idx].level > object_level)
2166 int d = (k_info[k_idx].level - object_level) * 5;
2167 if (!one_in_(d)) continue;
2170 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2171 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2172 object_prep(o_ptr, k_idx);
2175 random_artifact_resistance(o_ptr, a_ptr);
2179 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2185 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2186 * Mega-Hack -- Attempt to create one of the "Special Objects"
2187 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2188 * @return 生成に成功したらTRUEを返す。
2190 * Attempt to change an object into an artifact\n
2191 * This routine should only be called by "apply_magic()"\n
2192 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2194 static bool make_artifact(object_type *o_ptr)
2199 /* No artifacts in the town */
2200 if (!dun_level) return (FALSE);
2202 /* Paranoia -- no "plural" artifacts */
2203 if (o_ptr->number != 1) return (FALSE);
2205 /* Check the artifact list (skip the "specials") */
2206 for (i = 0; i < max_a_idx; i++)
2208 artifact_type *a_ptr = &a_info[i];
2210 /* Skip "empty" items */
2211 if (!a_ptr->name) continue;
2213 /* Cannot make an artifact twice */
2214 if (a_ptr->cur_num) continue;
2216 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2218 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2220 /* Must have the correct fields */
2221 if (a_ptr->tval != o_ptr->tval) continue;
2222 if (a_ptr->sval != o_ptr->sval) continue;
2224 /* XXX XXX Enforce minimum "depth" (loosely) */
2225 if (a_ptr->level > dun_level)
2227 /* Acquire the "out-of-depth factor" */
2228 int d = (a_ptr->level - dun_level) * 2;
2230 /* Roll for out-of-depth creation */
2231 if (!one_in_(d)) continue;
2234 /* We must make the "rarity roll" */
2235 if (!one_in_(a_ptr->rarity)) continue;
2237 /* Hack -- mark the item as an artifact */
2240 /* Hack: Some artifacts get random extra powers */
2241 random_artifact_resistance(o_ptr, a_ptr);
2253 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2254 * Choose random ego type
2255 * @param slot 取得したいエゴの装備部位
2256 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2257 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2259 static byte get_random_ego(byte slot, bool good)
2262 ego_item_type *e_ptr;
2266 for (i = 1; i < max_e_idx; i++)
2270 if (e_ptr->slot == slot
2271 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2274 total += (255 / e_ptr->rarity);
2278 value = randint1(total);
2280 for (i = 1; i < max_e_idx; i++)
2284 if (e_ptr->slot == slot
2285 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2288 value -= (255 / e_ptr->rarity);
2289 if (value <= 0L) break;
2297 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2298 * Apply magic to an item known to be a "weapon"
2299 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2300 * @param level 生成基準階
2301 * @param power 生成ランク
2304 * Hack -- note special base damage dice boosting\n
2305 * Hack -- note special processing for weapon/digger\n
2307 static void a_m_aux_1(object_type *o_ptr, DEPTH level, int power)
2309 HIT_PROB tohit1 = randint1(5) + (HIT_PROB)m_bonus(5, level);
2310 HIT_POINT todam1 = randint1(5) + (HIT_POINT)m_bonus(5, level);
2312 HIT_PROB tohit2 = (HIT_PROB)m_bonus(10, level);
2313 HIT_POINT todam2 = (HIT_POINT)m_bonus(10, level);
2315 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2317 tohit2 = (tohit2+1)/2;
2318 todam2 = (todam2+1)/2;
2325 o_ptr->to_h += tohit1;
2326 o_ptr->to_d += todam1;
2332 o_ptr->to_h += tohit2;
2333 o_ptr->to_d += todam2;
2341 o_ptr->to_h -= tohit1;
2342 o_ptr->to_d -= todam1;
2347 /* Penalize again */
2348 o_ptr->to_h -= tohit2;
2349 o_ptr->to_d -= todam2;
2352 /* Cursed (if "bad") */
2353 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2356 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2359 switch (o_ptr->tval)
2366 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2367 create_artifact(o_ptr, FALSE);
2369 /* Special Ego-item */
2370 o_ptr->name2 = EGO_DIGGING;
2374 else if (power < -1)
2376 /* Hack -- Horrible digging bonus */
2377 o_ptr->pval = 0 - (5 + randint1(5));
2383 /* Hack -- Reverse digging bonus */
2384 o_ptr->pval = 0 - (o_ptr->pval);
2398 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2400 create_artifact(o_ptr, FALSE);
2405 /* Roll for an ego-item */
2406 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2407 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2409 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2411 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2416 switch (o_ptr->name2)
2419 if (one_in_(4) && (level > 40))
2420 add_flag(o_ptr->art_flags, TR_BLOWS);
2424 add_flag(o_ptr->art_flags, TR_RES_POIS);
2426 add_flag(o_ptr->art_flags, TR_WARNING);
2428 case EGO_KILL_DRAGON:
2430 add_flag(o_ptr->art_flags, TR_RES_POIS);
2434 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2436 case EGO_SLAYING_WEAPON:
2437 if (one_in_(3)) /* double damage */
2445 while (one_in_(o_ptr->dd));
2451 while (one_in_(o_ptr->ds));
2456 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2458 if (o_ptr->tval == TV_SWORD && one_in_(3))
2460 add_flag(o_ptr->art_flags, TR_VORPAL);
2465 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2471 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2473 add_flag(o_ptr->art_flags, TR_DEX);
2475 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2478 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, level) + 1;
2480 case EGO_EARTHQUAKES:
2481 if (one_in_(3) && (level > 60))
2482 add_flag(o_ptr->art_flags, TR_BLOWS);
2484 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, level);
2488 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2492 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2494 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2496 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2497 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2500 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2501 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2502 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2503 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2507 if (!o_ptr->art_name)
2509 /* Hack -- Super-charge the damage dice */
2510 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2512 /* Hack -- Lower the damage dice */
2513 if (o_ptr->dd > 9) o_ptr->dd = 9;
2518 else if (power < -1)
2520 /* Roll for ego-item */
2521 if (randint0(MAX_DEPTH) < level)
2525 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2526 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2532 switch (o_ptr->name2)
2535 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2536 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2538 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2539 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2540 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2541 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2542 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2543 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2557 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2559 create_artifact(o_ptr, FALSE);
2562 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2576 if (power > 2) /* power > 2 is debug only */
2578 create_artifact(o_ptr, FALSE);
2582 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2584 switch (o_ptr->name2)
2586 case EGO_SLAYING_BOLT:
2591 /* Hack -- super-charge the damage dice */
2592 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2594 /* Hack -- restrict the damage dice */
2595 if (o_ptr->dd > 9) o_ptr->dd = 9;
2599 else if (power < -1)
2601 /* Roll for ego-item */
2602 if (randint0(MAX_DEPTH) < level)
2604 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2614 * @brief ドラゴン装備にランダムな耐性を与える
2615 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2618 static void dragon_resist(object_type * o_ptr)
2623 one_dragon_ele_resistance(o_ptr);
2625 one_high_resistance(o_ptr);
2631 * @brief オブジェクトにランダムな強いESPを与える
2632 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2635 static bool add_esp_strong(object_type *o_ptr)
2637 bool nonliv = FALSE;
2639 switch (randint1(3))
2641 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2642 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2643 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2650 * @brief オブジェクトにランダムな弱いESPを与える
2651 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2652 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2655 static void add_esp_weak(object_type *o_ptr, bool extra)
2658 u32b weak_esp_list[] = {
2670 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2671 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2673 /* Add unduplicated weak esp flags randomly */
2674 for (i = 0; i < add_count; ++ i)
2676 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2678 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2679 weak_esp_list[choice] = weak_esp_list[i];
2685 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2686 * Apply magic to an item known to be "armor"
2687 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2688 * @param level 生成基準階
2689 * @param power 生成ランク
2692 * Hack -- note special processing for crown/helm\n
2693 * Hack -- note special processing for robe of permanence\n
2695 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2697 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
2698 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
2704 o_ptr->to_a += toac1;
2710 o_ptr->to_a += toac2;
2718 o_ptr->to_a -= toac1;
2723 /* Penalize again */
2724 o_ptr->to_a -= toac2;
2727 /* Cursed (if "bad") */
2728 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2733 switch (o_ptr->tval)
2737 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2738 create_artifact(o_ptr, FALSE);
2748 /* Hack -- Try for "Robes of the Magi" */
2749 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2750 (o_ptr->sval == SV_ROBE) &&
2751 (randint0(100) < 15))
2755 o_ptr->name2 = EGO_YOIYAMI;
2756 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2757 o_ptr->sval = SV_YOIYAMI_ROBE;
2763 o_ptr->name2 = EGO_PERMANENCE;
2768 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2770 create_artifact(o_ptr, FALSE);
2776 bool okay_flag = TRUE;
2778 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2780 switch (o_ptr->name2)
2783 if (o_ptr->tval != TV_HARD_ARMOR)
2789 if (o_ptr->tval != TV_SOFT_ARMOR)
2798 if (okay_flag) break;
2800 switch (o_ptr->name2)
2802 case EGO_RESISTANCE:
2804 add_flag(o_ptr->art_flags, TR_RES_POIS);
2807 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2808 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2812 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2814 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2816 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2817 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2819 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2820 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2821 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2822 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2823 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2824 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2825 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2826 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2829 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2830 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2831 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2832 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2833 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2834 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2847 if (o_ptr->sval == SV_DRAGON_SHIELD)
2849 dragon_resist(o_ptr);
2850 if (!one_in_(3)) break;
2856 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2858 create_artifact(o_ptr, FALSE);
2864 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2865 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2866 && o_ptr->name2 == EGO_S_DWARVEN)
2873 switch (o_ptr->name2)
2876 if (!one_in_(3)) one_high_resistance(o_ptr);
2877 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2879 case EGO_REFLECTION:
2880 if (o_ptr->sval == SV_MIRROR_SHIELD)
2885 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2886 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2895 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2897 dragon_resist(o_ptr);
2898 if (!one_in_(3)) break;
2902 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2904 create_artifact(o_ptr, FALSE);
2907 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2911 else if (power < -1)
2913 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2921 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2923 dragon_resist(o_ptr);
2924 if (!one_in_(3)) break;
2929 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2931 create_artifact(o_ptr, FALSE);
2934 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2936 switch (o_ptr->name2)
2938 case EGO_SLOW_DESCENT:
2941 one_high_resistance(o_ptr);
2947 else if (power < -1)
2949 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2960 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2962 create_artifact(o_ptr, FALSE);
2967 bool ok_flag = TRUE;
2968 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2970 switch (o_ptr->name2)
2973 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2974 else add_esp_weak(o_ptr, FALSE);
2978 case EGO_REGENERATION:
2979 case EGO_LORDLINESS:
2985 if (one_in_(2)) add_esp_strong(o_ptr);
2986 else add_esp_weak(o_ptr, FALSE);
2989 default:/* not existing crown (wisdom,lite, etc...) */
2993 break; /* while (1) */
2999 else if (power < -1)
3003 bool ok_flag = TRUE;
3004 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3006 switch (o_ptr->name2)
3008 case EGO_ANCIENT_CURSE:
3009 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3010 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3011 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3012 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3013 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3014 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3018 break; /* while (1) */
3027 if (o_ptr->sval == SV_DRAGON_HELM)
3029 dragon_resist(o_ptr);
3030 if (!one_in_(3)) break;
3036 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3038 create_artifact(o_ptr, FALSE);
3043 bool ok_flag = TRUE;
3044 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3046 switch (o_ptr->name2)
3048 case EGO_BRILLIANCE:
3050 case EGO_INFRAVISION:
3051 case EGO_H_PROTECTION:
3056 if (one_in_(2)) add_esp_strong(o_ptr);
3057 else add_esp_weak(o_ptr, FALSE);
3061 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3062 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3065 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3067 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3069 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3070 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3072 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3073 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3074 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3075 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3076 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3077 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3078 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3079 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3081 default:/* not existing helm (Magi, Might, etc...)*/
3085 break; /* while (1) */
3090 else if (power < -1)
3094 bool ok_flag = TRUE;
3095 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3097 switch (o_ptr->name2)
3099 case EGO_ANCIENT_CURSE:
3103 break; /* while (1) */
3114 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3116 create_artifact(o_ptr, FALSE);
3119 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3121 switch (o_ptr->name2)
3130 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3131 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3132 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3133 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3140 else if (power < -1)
3142 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3153 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3154 * Apply magic to an item known to be a "ring" or "amulet"
3155 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3156 * @param level 生成基準階
3157 * @param power 生成ランク
3160 * Hack -- note special "pval boost" code for ring of speed\n
3161 * Hack -- note that some items must be cursed (or blessed)\n
3163 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3165 /* Apply magic (good or bad) according to type */
3166 switch (o_ptr->tval)
3171 switch (o_ptr->sval)
3173 case SV_RING_ATTACKS:
3176 o_ptr->pval = (PARAMETER_VALUE)m_bonus(2, level);
3177 if (one_in_(15)) o_ptr->pval++;
3178 if (o_ptr->pval < 1) o_ptr->pval = 1;
3184 o_ptr->ident |= (IDENT_BROKEN);
3187 o_ptr->curse_flags |= TRC_CURSED;
3190 o_ptr->pval = 0 - (o_ptr->pval);
3201 /* Strength, Constitution, Dexterity, Intelligence */
3207 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3213 o_ptr->ident |= (IDENT_BROKEN);
3216 o_ptr->curse_flags |= TRC_CURSED;
3219 o_ptr->pval = 0 - (o_ptr->pval);
3225 /* Ring of Speed! */
3228 /* Base speed (1 to 10) */
3229 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3231 /* Super-charge the ring */
3232 while (randint0(100) < 50) o_ptr->pval++;
3238 o_ptr->ident |= (IDENT_BROKEN);
3241 o_ptr->curse_flags |= TRC_CURSED;
3244 o_ptr->pval = 0 - (o_ptr->pval);
3252 case SV_RING_LORDLY:
3256 one_lordly_high_resistance(o_ptr);
3260 /* Bonus to armor class */
3261 o_ptr->to_a = 10 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3265 case SV_RING_WARNING:
3267 if (one_in_(3)) one_low_esp(o_ptr);
3272 case SV_RING_SEARCHING:
3274 /* Bonus to searching */
3275 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3281 o_ptr->ident |= (IDENT_BROKEN);
3284 o_ptr->curse_flags |= TRC_CURSED;
3287 o_ptr->pval = 0 - (o_ptr->pval);
3293 /* Flames, Acid, Ice */
3294 case SV_RING_FLAMES:
3299 /* Bonus to armor class */
3300 o_ptr->to_a = 5 + randint1(5) + (ARMOUR_CLASS)m_bonus(10, level);
3304 /* Weakness, Stupidity */
3305 case SV_RING_WEAKNESS:
3306 case SV_RING_STUPIDITY:
3309 o_ptr->ident |= (IDENT_BROKEN);
3312 o_ptr->curse_flags |= TRC_CURSED;
3315 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3316 if (power > 0) power = 0 - power;
3321 /* WOE, Stupidity */
3325 o_ptr->ident |= (IDENT_BROKEN);
3328 o_ptr->curse_flags |= TRC_CURSED;
3331 o_ptr->to_a = 0 - (5 + (ARMOUR_CLASS)m_bonus(10, level));
3332 o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, level));
3333 if (power > 0) power = 0 - power;
3338 /* Ring of damage */
3339 case SV_RING_DAMAGE:
3341 /* Bonus to damage */
3342 o_ptr->to_d = 1 + randint1(5) + (HIT_POINT)m_bonus(16, level);
3348 o_ptr->ident |= (IDENT_BROKEN);
3351 o_ptr->curse_flags |= TRC_CURSED;
3354 o_ptr->to_d = 0 - o_ptr->to_d;
3360 /* Ring of Accuracy */
3361 case SV_RING_ACCURACY:
3364 o_ptr->to_h = 1 + randint1(5) + (HIT_PROB)m_bonus(16, level);
3370 o_ptr->ident |= (IDENT_BROKEN);
3373 o_ptr->curse_flags |= TRC_CURSED;
3376 o_ptr->to_h = 0 - o_ptr->to_h;
3382 /* Ring of Protection */
3383 case SV_RING_PROTECTION:
3385 /* Bonus to armor class */
3386 o_ptr->to_a = 5 + randint1(8) + (ARMOUR_CLASS)m_bonus(10, level);
3392 o_ptr->ident |= (IDENT_BROKEN);
3395 o_ptr->curse_flags |= TRC_CURSED;
3398 o_ptr->to_a = 0 - o_ptr->to_a;
3404 /* Ring of Slaying */
3405 case SV_RING_SLAYING:
3407 /* Bonus to damage and to hit */
3408 o_ptr->to_d = randint1(5) + (HIT_POINT)m_bonus(12, level);
3409 o_ptr->to_h = randint1(5) + (HIT_PROB)m_bonus(12, level);
3415 o_ptr->ident |= (IDENT_BROKEN);
3418 o_ptr->curse_flags |= TRC_CURSED;
3420 /* Reverse bonuses */
3421 o_ptr->to_h = 0 - o_ptr->to_h;
3422 o_ptr->to_d = 0 - o_ptr->to_d;
3428 case SV_RING_MUSCLE:
3430 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(3, level);
3431 if (one_in_(4)) o_ptr->pval++;
3437 o_ptr->ident |= (IDENT_BROKEN);
3440 o_ptr->curse_flags |= TRC_CURSED;
3442 /* Reverse bonuses */
3443 o_ptr->pval = 0 - o_ptr->pval;
3448 case SV_RING_AGGRAVATION:
3451 o_ptr->ident |= (IDENT_BROKEN);
3454 o_ptr->curse_flags |= TRC_CURSED;
3456 if (power > 0) power = 0 - power;
3460 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3461 || (power > 2)) /* power > 2 is debug only */
3463 o_ptr->pval = MIN(o_ptr->pval, 4);
3464 /* Randart amulet */
3465 create_artifact(o_ptr, FALSE);
3467 else if ((power == 2) && one_in_(2))
3469 while(!o_ptr->name2)
3471 int tmp = m_bonus(10, level);
3472 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3473 switch(randint1(28))
3476 o_ptr->name2 = EGO_RING_THROW;
3479 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3480 o_ptr->name2 = EGO_RING_REGEN;
3483 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3484 o_ptr->name2 = EGO_RING_LITE;
3487 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3488 o_ptr->name2 = EGO_RING_TELEPORT;
3491 if (o_ptr->to_h) break;
3492 o_ptr->name2 = EGO_RING_TO_H;
3495 if (o_ptr->to_d) break;
3496 o_ptr->name2 = EGO_RING_TO_D;
3499 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3500 o_ptr->name2 = EGO_RING_SLAY;
3503 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3504 o_ptr->name2 = EGO_RING_WIZARD;
3507 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3508 o_ptr->name2 = EGO_RING_HERO;
3511 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3512 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3513 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3514 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3517 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3518 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;
3519 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3520 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3521 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3524 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3525 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;
3526 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3527 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3528 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3531 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3532 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;
3533 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3534 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3537 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3538 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;
3539 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3540 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3542 case 21: case 22: case 23: case 24: case 25: case 26:
3543 switch (o_ptr->sval)
3546 if (!one_in_(3)) break;
3547 o_ptr->name2 = EGO_RING_D_SPEED;
3549 case SV_RING_DAMAGE:
3550 case SV_RING_ACCURACY:
3551 case SV_RING_SLAYING:
3552 if (one_in_(2)) break;
3553 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3556 o_ptr->name2 = EGO_RING_BERSERKER;
3557 o_ptr->to_h -= 2+randint1(4);
3558 o_ptr->to_d += 2+randint1(4);
3561 case SV_RING_PROTECTION:
3562 o_ptr->name2 = EGO_RING_SUPER_AC;
3563 o_ptr->to_a += 7 + m_bonus(5, level);
3565 case SV_RING_RES_FEAR:
3566 o_ptr->name2 = EGO_RING_HERO;
3569 if (one_in_(2)) break;
3570 o_ptr->name2 = EGO_RING_HUNTER;
3572 case SV_RING_SEARCHING:
3573 o_ptr->name2 = EGO_RING_STEALTH;
3575 case SV_RING_TELEPORTATION:
3576 o_ptr->name2 = EGO_RING_TELE_AWAY;
3578 case SV_RING_RES_BLINDNESS:
3580 o_ptr->name2 = EGO_RING_RES_LITE;
3582 o_ptr->name2 = EGO_RING_RES_DARK;
3584 case SV_RING_LORDLY:
3585 if (!one_in_(20)) break;
3586 one_lordly_high_resistance(o_ptr);
3587 one_lordly_high_resistance(o_ptr);
3588 o_ptr->name2 = EGO_RING_TRUE;
3590 case SV_RING_SUSTAIN:
3591 if (!one_in_(4)) break;
3592 o_ptr->name2 = EGO_RING_RES_TIME;
3594 case SV_RING_FLAMES:
3595 if (!one_in_(2)) break;
3596 o_ptr->name2 = EGO_RING_DRAGON_F;
3599 if (!one_in_(2)) break;
3600 o_ptr->name2 = EGO_RING_DRAGON_C;
3602 case SV_RING_WARNING:
3603 if (!one_in_(2)) break;
3604 o_ptr->name2 = EGO_RING_M_DETECT;
3613 o_ptr->curse_flags = 0L;
3615 else if ((power == -2) && one_in_(2))
3617 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3618 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3619 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3620 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3621 o_ptr->art_flags[0] = 0;
3622 o_ptr->art_flags[1] = 0;
3623 while(!o_ptr->name2)
3625 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3629 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3630 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3633 o_ptr->name2 = EGO_RING_NO_MELEE;
3636 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3637 o_ptr->name2 = EGO_RING_AGGRAVATE;
3640 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3641 o_ptr->name2 = EGO_RING_TY_CURSE;
3644 o_ptr->name2 = EGO_RING_ALBINO;
3649 o_ptr->ident |= (IDENT_BROKEN);
3652 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3660 switch (o_ptr->sval)
3662 /* Amulet of wisdom/charisma */
3663 case SV_AMULET_INTELLIGENCE:
3664 case SV_AMULET_WISDOM:
3665 case SV_AMULET_CHARISMA:
3667 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, level);
3673 o_ptr->ident |= (IDENT_BROKEN);
3676 o_ptr->curse_flags |= (TRC_CURSED);
3678 /* Reverse bonuses */
3679 o_ptr->pval = 0 - o_ptr->pval;
3685 /* Amulet of brilliance */
3686 case SV_AMULET_BRILLIANCE:
3688 o_ptr->pval = 1 + m_bonus(3, level);
3689 if (one_in_(4)) o_ptr->pval++;
3695 o_ptr->ident |= (IDENT_BROKEN);
3698 o_ptr->curse_flags |= (TRC_CURSED);
3700 /* Reverse bonuses */
3701 o_ptr->pval = 0 - o_ptr->pval;
3707 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3711 o_ptr->curse_flags |= (TRC_CURSED);
3716 case SV_AMULET_RESISTANCE:
3718 if (one_in_(5)) one_high_resistance(o_ptr);
3719 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3723 /* Amulet of searching */
3724 case SV_AMULET_SEARCHING:
3726 o_ptr->pval = randint1(2) + (PARAMETER_VALUE)m_bonus(4, level);
3732 o_ptr->ident |= (IDENT_BROKEN);
3735 o_ptr->curse_flags |= (TRC_CURSED);
3737 /* Reverse bonuses */
3738 o_ptr->pval = 0 - (o_ptr->pval);
3744 /* Amulet of the Magi -- never cursed */
3745 case SV_AMULET_THE_MAGI:
3747 o_ptr->pval = randint1(5) + (PARAMETER_VALUE)m_bonus(5, level);
3748 o_ptr->to_a = randint1(5) + (ARMOUR_CLASS)m_bonus(5, level);
3750 /* gain one low ESP */
3751 add_esp_weak(o_ptr, FALSE);
3756 /* Amulet of Doom -- always cursed */
3757 case SV_AMULET_DOOM:
3760 o_ptr->ident |= (IDENT_BROKEN);
3763 o_ptr->curse_flags |= (TRC_CURSED);
3766 o_ptr->pval = 0 - (randint1(5) + (PARAMETER_VALUE)m_bonus(5, level));
3767 o_ptr->to_a = 0 - (randint1(5) + (ARMOUR_CLASS)m_bonus(5, level));
3768 if (power > 0) power = 0 - power;
3773 case SV_AMULET_MAGIC_MASTERY:
3775 o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(4, level);
3781 o_ptr->ident |= (IDENT_BROKEN);
3784 o_ptr->curse_flags |= (TRC_CURSED);
3786 /* Reverse bonuses */
3787 o_ptr->pval = 0 - o_ptr->pval;
3793 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3794 || (power > 2)) /* power > 2 is debug only */
3796 o_ptr->pval = MIN(o_ptr->pval, 4);
3797 /* Randart amulet */
3798 create_artifact(o_ptr, FALSE);
3800 else if ((power == 2) && one_in_(2))
3802 while(!o_ptr->name2)
3804 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3805 switch(randint1(21))
3808 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3809 o_ptr->name2 = EGO_AMU_SLOW_D;
3812 if (o_ptr->pval) break;
3813 o_ptr->name2 = EGO_AMU_INFRA;
3816 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3817 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3820 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3821 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3824 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3825 o_ptr->name2 = EGO_AMU_LEVITATION;
3827 case 10: case 11: case 21:
3828 o_ptr->name2 = EGO_AMU_AC;
3831 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3832 if (m_bonus(10, level) > 8)
3833 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3835 o_ptr->name2 = EGO_AMU_RES_FIRE;
3838 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3839 if (m_bonus(10, level) > 8)
3840 o_ptr->name2 = EGO_AMU_RES_COLD_;
3842 o_ptr->name2 = EGO_AMU_RES_COLD;
3845 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3846 if (m_bonus(10, level) > 8)
3847 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3849 o_ptr->name2 = EGO_AMU_RES_ELEC;
3852 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3853 if (m_bonus(10, level) > 8)
3854 o_ptr->name2 = EGO_AMU_RES_ACID_;
3856 o_ptr->name2 = EGO_AMU_RES_ACID;
3858 case 16: case 17: case 18: case 19: case 20:
3859 switch (o_ptr->sval)
3861 case SV_AMULET_TELEPORT:
3862 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3863 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3864 else o_ptr->name2 = EGO_AMU_TELEPORT;
3866 case SV_AMULET_RESIST_ACID:
3867 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3869 case SV_AMULET_SEARCHING:
3870 o_ptr->name2 = EGO_AMU_STEALTH;
3872 case SV_AMULET_BRILLIANCE:
3873 if (!one_in_(3)) break;
3874 o_ptr->name2 = EGO_AMU_IDENT;
3876 case SV_AMULET_CHARISMA:
3877 if (!one_in_(3)) break;
3878 o_ptr->name2 = EGO_AMU_CHARM;
3880 case SV_AMULET_THE_MAGI:
3881 if (one_in_(2)) break;
3882 o_ptr->name2 = EGO_AMU_GREAT;
3884 case SV_AMULET_RESISTANCE:
3885 if (!one_in_(5)) break;
3886 o_ptr->name2 = EGO_AMU_DEFENDER;
3888 case SV_AMULET_TELEPATHY:
3889 if (!one_in_(3)) break;
3890 o_ptr->name2 = EGO_AMU_DETECTION;
3896 o_ptr->curse_flags = 0L;
3898 else if ((power == -2) && one_in_(2))
3900 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3901 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3902 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3903 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3904 o_ptr->art_flags[0] = 0;
3905 o_ptr->art_flags[1] = 0;
3906 while(!o_ptr->name2)
3908 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3912 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3913 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3916 o_ptr->name2 = EGO_AMU_FOOL;
3919 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3920 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3923 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3924 o_ptr->name2 = EGO_AMU_TY_CURSE;
3927 o_ptr->name2 = EGO_AMU_NAIVETY;
3932 o_ptr->ident |= (IDENT_BROKEN);
3935 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3943 * @brief モンスターが人形のベースにできるかを返す
3944 * @param r_idx チェックしたいモンスター種族のID
3945 * @return 人形にできるならTRUEを返す
3947 static bool item_monster_okay(MONRACE_IDX r_idx)
3949 monster_race *r_ptr = &r_info[r_idx];
3952 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3953 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3954 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3955 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3956 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3957 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3965 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3966 * Apply magic to an item known to be "boring"
3967 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3968 * @param level 生成基準階
3969 * @param power 生成ランク
3972 * Hack -- note the special code for various items
3974 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3976 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3981 /* Apply magic (good or bad) according to type */
3982 switch (o_ptr->tval)
3991 o_ptr->ident |= (IDENT_BROKEN);
3994 o_ptr->curse_flags |= (TRC_CURSED);
4001 o_ptr->xtra4 = o_ptr->pval;
4007 /* Hack -- Torches -- random fuel */
4008 if (o_ptr->sval == SV_LITE_TORCH)
4010 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4014 /* Hack -- Lanterns -- random fuel */
4015 if (o_ptr->sval == SV_LITE_LANTERN)
4017 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4021 if (power > 2) /* power > 2 is debug only */
4023 create_artifact(o_ptr, FALSE);
4025 else if ((power == 2) || ((power == 1) && one_in_(3)))
4027 while (!o_ptr->name2)
4031 bool okay_flag = TRUE;
4033 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4035 switch (o_ptr->name2)
4038 if (o_ptr->sval == SV_LITE_FEANOR)
4046 else if (power == -2)
4048 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4050 switch (o_ptr->name2)
4052 case EGO_LITE_DARKNESS:
4055 if (o_ptr->sval == SV_LITE_TORCH)
4057 add_flag(o_ptr->art_flags, TR_LITE_M1);
4059 else if (o_ptr->sval == SV_LITE_LANTERN)
4061 add_flag(o_ptr->art_flags, TR_LITE_M2);
4063 else if (o_ptr->sval == SV_LITE_FEANOR)
4065 add_flag(o_ptr->art_flags, TR_LITE_M3);
4077 /* The wand or staff gets a number of initial charges equal
4078 * to between 1/2 (+1) and the full object kind's pval. -LM-
4080 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4086 /* Transfer the pval. -LM- */
4087 o_ptr->pval = k_ptr->pval;
4094 object_aware(o_ptr);
4095 object_known(o_ptr);
4101 PARAMETER_VALUE i = 1;
4104 monster_race *r_ptr;
4106 /* Pick a random non-unique monster race */
4109 i = randint1(max_r_idx - 1);
4111 if (!item_monster_okay(i)) continue;
4112 if (i == MON_TSUCHINOKO) continue;
4116 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4118 /* Ignore dead monsters */
4119 if (!r_ptr->rarity) continue;
4121 /* Ignore uncommon monsters */
4122 if (r_ptr->rarity > 100) continue;
4124 /* Prefer less out-of-depth monsters */
4125 if (randint0(check)) continue;
4132 /* Some figurines are cursed */
4133 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4140 PARAMETER_VALUE i = 1;
4145 monster_race *r_ptr;
4147 if (o_ptr->sval == SV_SKELETON)
4149 match = RF9_DROP_SKELETON;
4151 else if (o_ptr->sval == SV_CORPSE)
4153 match = RF9_DROP_CORPSE;
4156 /* Hack -- Remove the monster restriction */
4157 get_mon_num_prep(item_monster_okay, NULL);
4159 /* Pick a random non-unique monster race */
4162 i = get_mon_num(dun_level);
4166 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4168 /* Ignore dead monsters */
4169 if (!r_ptr->rarity) continue;
4171 /* Ignore corpseless monsters */
4172 if (!(r_ptr->flags9 & match)) continue;
4174 /* Prefer less out-of-depth monsters */
4175 if (randint0(check)) continue;
4183 object_aware(o_ptr);
4184 object_known(o_ptr);
4190 PARAMETER_VALUE i = 1;
4192 monster_race *r_ptr;
4194 /* Pick a random monster race */
4197 i = randint1(max_r_idx - 1);
4201 /* Ignore dead monsters */
4202 if (!r_ptr->rarity) continue;
4211 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4213 object_aware(o_ptr);
4214 object_known(o_ptr);
4221 DEPTH obj_level = k_info[o_ptr->k_idx].level;
4223 /* Hack -- skip ruined chests */
4224 if (obj_level <= 0) break;
4226 /* Hack -- pick a "difficulty" */
4227 o_ptr->pval = randint1(obj_level);
4228 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4230 o_ptr->xtra3 = dun_level + 5;
4232 /* Never exceed "difficulty" of 55 to 59 */
4233 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4241 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4242 * Complete the "creation" of an object by applying "magic" to the item
4243 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4245 * @param mode 生成オプション
4248 * This includes not only rolling for random bonuses, but also putting the\n
4249 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4250 * staffs, giving fuel to lites, and placing traps on chests.\n
4252 * In particular, note that "Instant Artifacts", if "created" by an external\n
4253 * routine, must pass through this function to complete the actual creation.\n
4255 * The base "chance" of the item being "good" increases with the "level"\n
4256 * parameter, which is usually derived from the dungeon level, being equal\n
4257 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4258 * the object is guaranteed to be "good". If an object is "good", then\n
4259 * the chance that the object will be "great" (ego-item or artifact), also\n
4260 * increases with the "level", being equal to half the level, plus 5, up to\n
4261 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4262 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4264 * If the object is not "good", there is a chance it will be "cursed", and\n
4265 * if it is "cursed", there is a chance it will be "broken". These chances\n
4266 * are related to the "good" / "great" chances above.\n
4268 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4269 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4271 * If "okay" is true, and the object is going to be "great", then there is\n
4272 * a chance that an artifact will be created. This is true even if both the\n
4273 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4274 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4276 void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
4278 int i, rolls, f1, f2, power;
4280 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4282 /* Maximum "level" for various things */
4283 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4285 /* Base chance of being "good" */
4288 /* Maximal chance of being "good" */
4289 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4291 /* Base chance of being "great" */
4294 /* Maximal chance of being "great" */
4295 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4296 f2 = d_info[dungeon_type].obj_great;
4298 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4303 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4312 /* Roll for "good" */
4313 if ((mode & AM_GOOD) || magik(f1))
4318 /* Roll for "great" */
4319 if ((mode & AM_GREAT) || magik(f2))
4323 /* Roll for "special" */
4324 if (mode & AM_SPECIAL) power = 3;
4328 /* Roll for "cursed" */
4331 /* Assume "cursed" */
4334 /* Roll for "broken" */
4335 if (magik(f2)) power = -2;
4339 if (mode & AM_CURSED)
4341 /* Assume 'cursed' */
4346 /* Everything else gets more badly cursed */
4353 /* Assume no rolls */
4356 /* Get one roll if excellent */
4357 if (power >= 2) rolls = 1;
4359 /* Hack -- Get four rolls if forced great or special */
4360 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4362 /* Hack -- Get no rolls if not allowed */
4363 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4365 /* Roll for artifacts if allowed */
4366 for (i = 0; i < rolls; i++)
4368 /* Roll for an artifact */
4369 if (make_artifact(o_ptr)) break;
4370 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4372 if (make_artifact(o_ptr)) break;
4377 /* Hack -- analyze artifacts */
4378 if (object_is_fixed_artifact(o_ptr))
4380 artifact_type *a_ptr = &a_info[o_ptr->name1];
4382 /* Hack -- Mark the artifact as "created" */
4385 /* Hack -- Memorize location of artifact in saved floors */
4386 if (character_dungeon)
4387 a_ptr->floor_id = p_ptr->floor_id;
4389 /* Extract the other fields */
4390 o_ptr->pval = a_ptr->pval;
4391 o_ptr->ac = a_ptr->ac;
4392 o_ptr->dd = a_ptr->dd;
4393 o_ptr->ds = a_ptr->ds;
4394 o_ptr->to_a = a_ptr->to_a;
4395 o_ptr->to_h = a_ptr->to_h;
4396 o_ptr->to_d = a_ptr->to_d;
4397 o_ptr->weight = a_ptr->weight;
4398 o_ptr->xtra2 = a_ptr->act_idx;
4400 if (o_ptr->name1 == ART_MILIM)
4402 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4408 /* Hack -- extract the "broken" flag */
4409 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4411 /* Hack -- extract the "cursed" flag */
4412 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4413 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4414 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4415 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4416 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4417 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4425 switch (o_ptr->tval)
4434 if (power) a_m_aux_1(o_ptr, lev, power);
4440 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4446 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4460 /* Elven Cloak and Black Clothes ... */
4461 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4462 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4463 o_ptr->pval = randint1(4);
4467 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4468 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4469 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4470 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4471 a_m_aux_2(o_ptr, lev, power);
4473 if (power) a_m_aux_2(o_ptr, lev, power);
4481 if (!power && (randint0(100) < 50)) power = -1;
4482 a_m_aux_3(o_ptr, lev, power);
4488 a_m_aux_4(o_ptr, lev, power);
4493 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4494 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4495 (p_ptr->pseikaku == SEIKAKU_SEXY))
4498 add_flag(o_ptr->art_flags, TR_STR);
4499 add_flag(o_ptr->art_flags, TR_INT);
4500 add_flag(o_ptr->art_flags, TR_WIS);
4501 add_flag(o_ptr->art_flags, TR_DEX);
4502 add_flag(o_ptr->art_flags, TR_CON);
4503 add_flag(o_ptr->art_flags, TR_CHR);
4506 /* Hack -- analyze ego-items */
4507 if (object_is_ego(o_ptr))
4509 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4511 /* Hack -- acquire "broken" flag */
4512 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4514 /* Hack -- acquire "cursed" flag */
4515 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4516 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4517 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4518 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4519 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4520 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4522 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4523 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4524 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4525 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4526 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4527 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4528 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4529 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4535 while (one_in_(o_ptr->dd));
4537 if (o_ptr->dd > 9) o_ptr->dd = 9;
4540 /* Hack -- apply activatin index if needed */
4541 if (e_ptr->act_idx) o_ptr->xtra2 = (XTRA8)e_ptr->act_idx;
4543 /* Hack -- apply extra penalties if needed */
4544 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4546 /* Hack -- obtain bonuses */
4547 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4548 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4549 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4551 /* Hack -- obtain pval */
4552 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4555 /* Hack -- apply extra bonuses if needed */
4558 /* Hack -- obtain bonuses */
4559 if (e_ptr->max_to_h)
4561 if (e_ptr->max_to_h > 127)
4562 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4563 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4565 if (e_ptr->max_to_d)
4567 if (e_ptr->max_to_d > 127)
4568 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4569 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4571 if (e_ptr->max_to_a)
4573 if (e_ptr->max_to_a > 127)
4574 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4575 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4578 /* Accuracy ego must have high to_h */
4579 if(o_ptr->name2 == EGO_ACCURACY)
4581 while(o_ptr->to_h < o_ptr->to_d + 10)
4586 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4589 /* Accuracy ego must have high to_h */
4590 if(o_ptr->name2 == EGO_VELOCITY)
4592 while(o_ptr->to_d < o_ptr->to_h + 10)
4597 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4600 /* Protection ego must have high to_a */
4601 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4603 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4606 /* Hack -- obtain pval */
4607 if (e_ptr->max_pval)
4609 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4612 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4614 else if (o_ptr->name2 == EGO_DEMON)
4616 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4618 o_ptr->pval += randint1(2);
4622 o_ptr->pval += randint1(e_ptr->max_pval);
4625 else if (o_ptr->name2 == EGO_ATTACKS)
4627 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4628 if (o_ptr->pval > 3) o_ptr->pval = 3;
4629 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4630 o_ptr->pval += randint1(2);
4632 else if (o_ptr->name2 == EGO_BAT)
4634 o_ptr->pval = randint1(e_ptr->max_pval);
4635 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4637 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4639 o_ptr->pval = randint1(e_ptr->max_pval);
4643 o_ptr->pval += randint1(e_ptr->max_pval);
4648 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4650 o_ptr->pval = randint1(o_ptr->pval);
4652 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4660 /* Examine real objects */
4663 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4665 /* Hack -- acquire "broken" flag */
4666 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4668 /* Hack -- acquire "cursed" flag */
4669 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4670 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4671 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4672 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4673 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4674 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4682 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4683 * Hack -- determine if a template is "good"
4684 * @param k_idx 判定したいベースアイテムのID
4685 * @return ベースアイテムが上質ならばTRUEを返す。
4687 static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4689 object_kind *k_ptr = &k_info[k_idx];
4691 /* Analyze the item type */
4692 switch (k_ptr->tval)
4694 /* Armor -- Good unless damaged */
4705 if (k_ptr->to_a < 0) return (FALSE);
4709 /* Weapons -- Good unless damaged */
4716 if (k_ptr->to_h < 0) return (FALSE);
4717 if (k_ptr->to_d < 0) return (FALSE);
4721 /* Ammo -- Arrows/Bolts are good */
4728 /* Books -- High level books are good (except Arcane books) */
4730 case TV_SORCERY_BOOK:
4731 case TV_NATURE_BOOK:
4736 case TV_DAEMON_BOOK:
4737 case TV_CRUSADE_BOOK:
4739 case TV_HISSATSU_BOOK:
4742 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4746 /* Rings -- Rings of Speed are good */
4749 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4750 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4754 /* Amulets -- Amulets of the Magi and Resistance are good */
4757 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4758 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4763 /* Assume not good */
4768 * @brief 生成階に応じたベースアイテムの生成を行う。
4769 * Attempt to make an object (normal or good/great)
4770 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4771 * @param mode オプションフラグ
4772 * @return 生成に成功したらTRUEを返す。
4774 * This routine plays nasty games to generate the "special artifacts".\n
4775 * This routine uses "object_level" for the "generation level".\n
4776 * We assume that the given object has been "wiped".\n
4778 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
4783 /* Chance of "special object" */
4784 prob = ((mode & AM_GOOD) ? 10 : 1000);
4786 /* Base level for the object */
4787 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4790 /* Generate a special object, or a normal object */
4791 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4796 if ((mode & AM_GOOD) && !get_obj_num_hook)
4798 /* Activate restriction (if already specified, use that) */
4799 get_obj_num_hook = kind_is_good;
4802 /* Restricted objects - prepare allocation table */
4803 if (get_obj_num_hook) get_obj_num_prep();
4805 /* Pick a random object */
4806 k_idx = get_obj_num(base);
4808 /* Restricted objects */
4809 if (get_obj_num_hook)
4811 /* Clear restriction */
4812 get_obj_num_hook = NULL;
4814 /* Reset allocation table to default */
4818 /* Handle failure */
4819 if (!k_idx) return (FALSE);
4821 /* Prepare the object */
4822 object_prep(j_ptr, k_idx);
4825 /* Apply magic (allow artifacts) */
4826 apply_magic(j_ptr, object_level, mode);
4828 /* Hack -- generate multiple spikes/missiles */
4829 switch (j_ptr->tval)
4837 j_ptr->number = (byte)damroll(6, 7);
4841 if (cheat_peek) object_mention(j_ptr);
4849 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4850 * Attempt to place an object (normal or good/great) at the given location.
4851 * @param y 配置したいフロアのY座標
4852 * @param x 配置したいフロアのX座標
4853 * @param mode オプションフラグ
4854 * @return 生成に成功したらTRUEを返す。
4856 * This routine plays nasty games to generate the "special artifacts".\n
4857 * This routine uses "object_level" for the "generation level".\n
4858 * This routine requires a clean floor grid destination.\n
4860 void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
4865 cave_type *c_ptr = &cave[y][x];
4871 /* Paranoia -- check bounds */
4872 if (!in_bounds(y, x)) return;
4874 /* Require floor space */
4875 if (!cave_drop_bold(y, x)) return;
4877 /* Avoid stacking on other objects */
4878 if (c_ptr->o_idx) return;
4881 /* Get local object */
4884 /* Wipe the object */
4887 /* Make an object (if possible) */
4888 if (!make_object(q_ptr, mode)) return;
4891 /* Make an object */
4899 /* Acquire object */
4900 o_ptr = &o_list[o_idx];
4902 /* Structure Copy */
4903 object_copy(o_ptr, q_ptr);
4910 o_ptr->next_o_idx = c_ptr->o_idx;
4912 /* Place the object */
4913 c_ptr->o_idx = o_idx;
4923 /* Hack -- Preserve artifacts */
4924 if (object_is_fixed_artifact(q_ptr))
4926 a_info[q_ptr->name1].cur_num = 0;
4933 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4934 * Make a treasure object
4935 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4936 * @return 生成に成功したらTRUEを返す。
4938 * The location must be a legal, clean, floor grid.
4940 bool make_gold(object_type *j_ptr)
4947 /* Hack -- Pick a Treasure variety */
4948 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4950 /* Apply "extra" magic */
4951 if (one_in_(GREAT_OBJ))
4953 i += randint1(object_level + 1);
4956 /* Hack -- Creeping Coins only generate "themselves" */
4957 if (coin_type) i = coin_type;
4959 /* Do not create "illegal" Treasure Types */
4960 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4962 /* Prepare a gold object */
4963 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4965 /* Hack -- Base coin cost */
4966 base = k_info[OBJ_GOLD_LIST+i].cost;
4968 /* Determine how much the treasure is "worth" */
4969 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
4977 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
4978 * Places a treasure (Gold or Gems) at given location
4979 * @param y 配置したいフロアのY座標
4980 * @param x 配置したいフロアのX座標
4981 * @return 生成に成功したらTRUEを返す。
4983 * The location must be a legal, clean, floor grid.
4985 void place_gold(POSITION y, POSITION x)
4990 cave_type *c_ptr = &cave[y][x];
4997 /* Paranoia -- check bounds */
4998 if (!in_bounds(y, x)) return;
5000 /* Require floor space */
5001 if (!cave_drop_bold(y, x)) return;
5003 /* Avoid stacking on other objects */
5004 if (c_ptr->o_idx) return;
5007 /* Get local object */
5010 /* Wipe the object */
5013 /* Make some gold */
5014 if (!make_gold(q_ptr)) return;
5017 /* Make an object */
5025 /* Acquire object */
5026 o_ptr = &o_list[o_idx];
5028 /* Copy the object */
5029 object_copy(o_ptr, q_ptr);
5036 o_ptr->next_o_idx = c_ptr->o_idx;
5038 /* Place the object */
5039 c_ptr->o_idx = o_idx;
5051 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5052 * Let an object fall to the ground at or near a location.
5053 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5054 * @param chance ドロップの成功率(%)
5055 * @param y 配置したいフロアのY座標
5056 * @param x 配置したいフロアのX座標
5057 * @return 生成に成功したらTRUEを返す。
5059 * The initial location is assumed to be "in_bounds()".\n
5061 * This function takes a parameter "chance". This is the percentage\n
5062 * chance that the item will "disappear" instead of drop. If the object\n
5063 * has been thrown, then this is the chance of disappearance on contact.\n
5065 * Hack -- this function uses "chance" to determine if it should produce\n
5066 * some form of "description" of the drop event (under the player).\n
5068 * We check several locations to see if we can find a location at which\n
5069 * the object can combine, stack, or be placed. Artifacts will try very\n
5070 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5072 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5083 s16b this_o_idx, next_o_idx = 0;
5087 char o_name[MAX_NLEN];
5093 /* Extract plural */
5094 bool plural = (j_ptr->number != 1);
5097 /* Describe object */
5098 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5101 /* Handle normal "breakage" */
5102 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5106 msg_format("%sは消えた。", o_name);
5108 msg_format("The %s disappear%s.",
5109 o_name, (plural ? "" : "s"));
5114 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5131 /* Scan local grids */
5132 for (dy = -3; dy <= 3; dy++)
5134 /* Scan local grids */
5135 for (dx = -3; dx <= 3; dx++)
5139 /* Calculate actual distance */
5140 d = (dy * dy) + (dx * dx);
5142 /* Ignore distant grids */
5143 if (d > 10) continue;
5149 /* Skip illegal grids */
5150 if (!in_bounds(ty, tx)) continue;
5152 /* Require line of projection */
5153 if (!projectable(y, x, ty, tx)) continue;
5156 c_ptr = &cave[ty][tx];
5158 /* Require floor space */
5159 if (!cave_drop_bold(ty, tx)) continue;
5164 /* Scan objects in that grid */
5165 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5169 /* Acquire object */
5170 o_ptr = &o_list[this_o_idx];
5172 /* Acquire next object */
5173 next_o_idx = o_ptr->next_o_idx;
5175 /* Check for possible combination */
5176 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5182 /* Add new object */
5186 if (k > 99) continue;
5188 /* Calculate score */
5189 s = 1000 - (d + k * 5);
5191 /* Skip bad values */
5192 if (s < bs) continue;
5194 /* New best value */
5197 /* Apply the randomizer to equivalent values */
5198 if ((++bn >= 2) && !one_in_(bn)) continue;
5213 /* Handle lack of space */
5214 if (!flag && !object_is_artifact(j_ptr))
5218 msg_format("%sは消えた。", o_name);
5220 msg_format("The %s disappear%s.",
5221 o_name, (plural ? "" : "s"));
5226 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5234 for (i = 0; !flag && (i < 1000); i++)
5237 ty = rand_spread(by, 1);
5238 tx = rand_spread(bx, 1);
5240 /* Verify location */
5241 if (!in_bounds(ty, tx)) continue;
5243 /* Bounce to that location */
5247 /* Require floor space */
5248 if (!cave_drop_bold(by, bx)) continue;
5257 int candidates = 0, pick;
5259 for (ty = 1; ty < cur_hgt - 1; ty++)
5261 for (tx = 1; tx < cur_wid - 1; tx++)
5263 /* A valid space found */
5264 if (cave_drop_bold(ty, tx)) candidates++;
5268 /* No valid place! */
5273 msg_format("%sは消えた。", o_name);
5275 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5279 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5281 /* Mega-Hack -- preserve artifacts */
5284 /* Hack -- Preserve unknown artifacts */
5285 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5287 /* Mega-Hack -- Preserve the artifact */
5288 a_info[j_ptr->name1].cur_num = 0;
5296 /* Choose a random one */
5297 pick = randint1(candidates);
5299 for (ty = 1; ty < cur_hgt - 1; ty++)
5301 for (tx = 1; tx < cur_wid - 1; tx++)
5303 if (cave_drop_bold(ty, tx))
5307 /* Is this a picked one? */
5321 c_ptr = &cave[by][bx];
5323 /* Scan objects in that grid for combination */
5324 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5328 /* Acquire object */
5329 o_ptr = &o_list[this_o_idx];
5331 /* Acquire next object */
5332 next_o_idx = o_ptr->next_o_idx;
5334 /* Check for combination */
5335 if (object_similar(o_ptr, j_ptr))
5337 /* Combine the items */
5338 object_absorb(o_ptr, j_ptr);
5348 /* Get new object */
5349 if (!done) o_idx = o_pop();
5352 if (!done && !o_idx)
5356 msg_format("%sは消えた。", o_name);
5358 msg_format("The %s disappear%s.",
5359 o_name, (plural ? "" : "s"));
5364 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5366 /* Hack -- Preserve artifacts */
5367 if (object_is_fixed_artifact(j_ptr))
5369 a_info[j_ptr->name1].cur_num = 0;
5379 /* Structure copy */
5380 object_copy(&o_list[o_idx], j_ptr);
5382 /* Access new object */
5383 j_ptr = &o_list[o_idx];
5390 j_ptr->held_m_idx = 0;
5393 j_ptr->next_o_idx = c_ptr->o_idx;
5395 /* Place the object */
5396 c_ptr->o_idx = o_idx;
5411 /* Mega-Hack -- no message if "dropped" by player */
5412 /* Message when an object falls under the player */
5413 if (chance && player_bold(by, bx))
5415 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5427 * Scatter some "great" objects near the player
5428 * @param y1 配置したいフロアのY座標
5429 * @param x1 配置したいフロアのX座標
5430 * @param num 獲得の処理回数
5431 * @param great TRUEならば必ず高級品以上を落とす
5432 * @param special TRUEならば必ず特別品を落とす
5433 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5436 void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
5439 object_type object_type_body;
5440 BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5445 /* Get local object */
5446 i_ptr = &object_type_body;
5448 /* Wipe the object */
5451 /* Make a good (or great) object (if possible) */
5452 if (!make_object(i_ptr, mode)) continue;
5456 object_aware(i_ptr);
5457 object_known(i_ptr);
5460 /* Drop the object */
5461 (void)drop_near(i_ptr, -1, y1, x1);
5466 * Scatter some "amusing" objects near the player
5469 #define AMS_NOTHING 0x00 /* No restriction */
5470 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5471 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5472 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5473 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5477 OBJECT_TYPE_VALUE tval;
5478 OBJECT_SUBTYPE_VALUE sval;
5483 amuse_type amuse_info[] =
5485 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5486 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5487 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5488 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5489 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5490 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5491 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5492 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5493 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5494 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5495 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5496 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5497 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5504 * @param y1 配置したいフロアのY座標
5505 * @param x1 配置したいフロアのX座標
5506 * @param num 誰得の処理回数
5507 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5510 void amusement(POSITION y1, POSITION x1, int num, bool known)
5513 object_type object_type_body;
5516 for (n = 0; amuse_info[n].tval != 0; n++)
5518 t += amuse_info[n].prob;
5525 IDX k_idx, a_idx = 0;
5526 int r = randint0(t);
5527 bool insta_art, fixed_art;
5531 r -= amuse_info[i].prob;
5535 /* Get local object */
5536 i_ptr = &object_type_body;
5538 /* Wipe the object */
5541 /* Wipe the object */
5542 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5544 /* Paranoia - reroll if nothing */
5545 if (!k_idx) continue;
5547 /* Search an artifact index if need */
5548 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5549 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5551 if (insta_art || fixed_art)
5553 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5555 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5556 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5557 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5558 if (a_info[a_idx].cur_num > 0) continue;
5562 if (a_idx >= max_a_idx) continue;
5565 /* Make an object (if possible) */
5566 object_prep(i_ptr, k_idx);
5567 if (a_idx) i_ptr->name1 = a_idx;
5568 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5570 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5572 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5575 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5576 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5580 object_aware(i_ptr);
5581 object_known(i_ptr);
5584 /* Paranoia - reroll if nothing */
5585 if (!(i_ptr->k_idx)) continue;
5587 /* Drop the object */
5588 (void)drop_near(i_ptr, -1, y1, x1);
5595 #define MAX_NORMAL_TRAPS 18
5597 /* See init_feat_variables() in init2.c */
5598 static s16b normal_traps[MAX_NORMAL_TRAPS];
5601 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5604 void init_normal_traps(void)
5608 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5609 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5610 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5611 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5612 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5613 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5614 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5615 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5616 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5617 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5618 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5619 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5620 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5621 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5622 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5623 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5624 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5625 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5629 * @brief 基本トラップをランダムに選択する /
5631 * @return 選択したトラップのID
5633 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5634 * That is, it does not make sense to have spiked pits at 50 feet.\n
5635 * Actually, it is not this routine, but the "trap instantiation"\n
5636 * code, which should also check for "trap doors" on quest levels.\n
5638 s16b choose_random_trap(void)
5645 /* Hack -- pick a trap */
5646 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5648 /* Accept non-trapdoors */
5649 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5651 /* Hack -- no trap doors on special levels */
5652 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5654 /* Hack -- no trap doors on the deepest level */
5655 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5664 * @brief マスに存在するトラップを秘匿する /
5665 * Disclose an invisible trap
5666 * @param y 秘匿したいマスのY座標
5667 * @param x 秘匿したいマスのX座標
5670 void disclose_grid(POSITION y, POSITION x)
5672 cave_type *c_ptr = &cave[y][x];
5674 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5676 /* No longer hidden */
5677 cave_alter_feat(y, x, FF_SECRET);
5679 else if (c_ptr->mimic)
5681 /* No longer hidden */
5693 * @brief マスをトラップを配置する /
5694 * The location must be a legal, naked, floor grid.
5695 * @param y 配置したいマスのY座標
5696 * @param x 配置したいマスのX座標
5698 * Note that all traps start out as "invisible" and "untyped", and then\n
5699 * when they are "discovered" (by detecting them or setting them off),\n
5700 * the trap is "instantiated" as a visible, "typed", trap.\n
5702 void place_trap(POSITION y, POSITION x)
5704 cave_type *c_ptr = &cave[y][x];
5706 /* Paranoia -- verify location */
5707 if (!in_bounds(y, x)) return;
5709 /* Require empty, clean, floor grid */
5710 if (!cave_clean_bold(y, x)) return;
5712 /* Place an invisible trap */
5713 c_ptr->mimic = c_ptr->feat;
5714 c_ptr->feat = choose_random_trap();
5718 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5719 * Describe the charges on an item in the inventory.
5720 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5723 void inven_item_charges(int item)
5725 object_type *o_ptr = &inventory[item];
5727 /* Require staff/wand */
5728 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5730 /* Require known item */
5731 if (!object_is_known(o_ptr)) return;
5734 if (o_ptr->pval <= 0)
5736 msg_print("もう魔力が残っていない。");
5740 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5743 /* Multiple charges */
5744 if (o_ptr->pval != 1)
5746 /* Print a message */
5747 msg_format("You have %d charges remaining.", o_ptr->pval);
5753 /* Print a message */
5754 msg_format("You have %d charge remaining.", o_ptr->pval);
5761 * @brief アイテムの残り所持数メッセージを表示する /
5762 * Describe an item in the inventory.
5763 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5766 void inven_item_describe(int item)
5768 object_type *o_ptr = &inventory[item];
5769 char o_name[MAX_NLEN];
5771 /* Get a description */
5772 object_desc(o_name, o_ptr, 0);
5774 /* Print a message */
5776 /* "no more" の場合はこちらで表示する */
5777 if (o_ptr->number <= 0)
5779 /*FIRST*//*ここはもう通らないかも */
5780 msg_format("もう%sを持っていない。", o_name);
5784 /* アイテム名を英日切り替え機能対応 */
5785 msg_format("まだ %sを持っている。", o_name);
5788 msg_format("You have %s.", o_name);
5794 * @brief アイテムの残り所持数メッセージを表示する /
5795 * Increase the "number" of an item in the inventory
5796 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5800 void inven_item_increase(int item, int num)
5802 object_type *o_ptr = &inventory[item];
5805 num += o_ptr->number;
5808 if (num > 255) num = 255;
5809 else if (num < 0) num = 0;
5812 num -= (ITEM_NUMBER)o_ptr->number;
5814 /* Change the number and weight */
5817 /* Add the number */
5818 o_ptr->number += num;
5820 /* Add the weight */
5821 p_ptr->total_weight += (num * o_ptr->weight);
5823 /* Recalculate bonuses */
5824 p_ptr->update |= (PU_BONUS);
5826 /* Recalculate mana XXX */
5827 p_ptr->update |= (PU_MANA);
5829 /* Combine the pack */
5830 p_ptr->notice |= (PN_COMBINE);
5833 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5835 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5836 if (!o_ptr->number && p_ptr->ele_attack)
5838 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5840 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5842 /* Clear all temporary elemental brands */
5843 set_ele_attack(0, 0);
5851 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5852 * Erase an inventory slot if it has no more items
5853 * @param item 消去したいプレイヤーのアイテム所持スロット
5856 void inven_item_optimize(int item)
5858 object_type *o_ptr = &inventory[item];
5860 /* Only optimize real items */
5861 if (!o_ptr->k_idx) return;
5863 /* Only optimize empty items */
5864 if (o_ptr->number) return;
5866 /* The item is in the pack */
5867 if (item < INVEN_RARM)
5874 /* Slide everything down */
5875 for (i = item; i < INVEN_PACK; i++)
5877 /* Structure copy */
5878 inventory[i] = inventory[i+1];
5881 /* Erase the "final" slot */
5882 object_wipe(&inventory[i]);
5885 p_ptr->window |= (PW_INVEN);
5888 /* The item is being wielded */
5894 /* Erase the empty slot */
5895 object_wipe(&inventory[item]);
5897 /* Recalculate bonuses */
5898 p_ptr->update |= (PU_BONUS);
5900 /* Recalculate torch */
5901 p_ptr->update |= (PU_TORCH);
5903 /* Recalculate mana XXX */
5904 p_ptr->update |= (PU_MANA);
5907 p_ptr->window |= (PW_EQUIP);
5911 p_ptr->window |= (PW_SPELL);
5915 * @brief 床上の魔道具の残り残量メッセージを表示する /
5916 * Describe the charges on an item on the floor.
5917 * @param item メッセージの対象にしたいアイテム所持スロット
5920 void floor_item_charges(int item)
5922 object_type *o_ptr = &o_list[item];
5924 /* Require staff/wand */
5925 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5927 /* Require known item */
5928 if (!object_is_known(o_ptr)) return;
5931 if (o_ptr->pval <= 0)
5933 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5937 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5940 /* Multiple charges */
5941 if (o_ptr->pval != 1)
5943 /* Print a message */
5944 msg_format("There are %d charges remaining.", o_ptr->pval);
5950 /* Print a message */
5951 msg_format("There is %d charge remaining.", o_ptr->pval);
5958 * @brief 床上のアイテムの残り数メッセージを表示する /
5959 * Describe the charges on an item on the floor.
5960 * @param item メッセージの対象にしたいアイテム所持スロット
5963 void floor_item_describe(int item)
5965 object_type *o_ptr = &o_list[item];
5966 char o_name[MAX_NLEN];
5968 /* Get a description */
5969 object_desc(o_name, o_ptr, 0);
5971 /* Print a message */
5973 /* "no more" の場合はこちらで表示を分ける */
5974 if (o_ptr->number <= 0)
5976 msg_format("床上には、もう%sはない。", o_name);
5980 msg_format("床上には、まだ %sがある。", o_name);
5983 msg_format("You see %s.", o_name);
5990 * @brief 床上のアイテムの数を増やす /
5991 * Increase the "number" of an item on the floor
5992 * @param item 増やしたいアイテムの所持スロット
5993 * @param num 増やしたいアイテムの数
5996 void floor_item_increase(int item, int num)
5998 object_type *o_ptr = &o_list[item];
6001 num += o_ptr->number;
6004 if (num > 255) num = 255;
6005 else if (num < 0) num = 0;
6008 num -= (int)o_ptr->number;
6010 /* Change the number */
6011 o_ptr->number += (ITEM_NUMBER)num;
6016 * @brief 床上の数の無くなったアイテムスロットを消去する /
6017 * Optimize an item on the floor (destroy "empty" items)
6018 * @param item 消去したいアイテムの所持スロット
6021 void floor_item_optimize(int item)
6023 object_type *o_ptr = &o_list[item];
6025 /* Paranoia -- be sure it exists */
6026 if (!o_ptr->k_idx) return;
6028 /* Only optimize empty items */
6029 if (o_ptr->number) return;
6031 /* Delete the object */
6032 delete_object_idx(item);
6037 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6038 * Check if we have space for an item in the pack without overflow
6039 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6040 * @return 溢れずに済むならTRUEを返す
6042 bool inven_carry_okay(object_type *o_ptr)
6047 if (inven_cnt < INVEN_PACK) return (TRUE);
6050 for (j = 0; j < INVEN_PACK; j++)
6052 object_type *j_ptr = &inventory[j];
6054 /* Skip non-objects */
6055 if (!j_ptr->k_idx) continue;
6057 /* Check if the two items can be combined */
6058 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6066 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6067 * Check if we have space for an item in the pack without overflow
6068 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6069 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6070 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6071 * @return o_ptrの方が上位ならばTRUEを返す。
6073 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6077 /* Use empty slots */
6078 if (!j_ptr->k_idx) return TRUE;
6080 /* Hack -- readable books always come first */
6081 if ((o_ptr->tval == REALM1_BOOK) &&
6082 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6083 if ((j_ptr->tval == REALM1_BOOK) &&
6084 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6086 if ((o_ptr->tval == REALM2_BOOK) &&
6087 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6088 if ((j_ptr->tval == REALM2_BOOK) &&
6089 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6091 /* Objects sort by decreasing type */
6092 if (o_ptr->tval > j_ptr->tval) return TRUE;
6093 if (o_ptr->tval < j_ptr->tval) return FALSE;
6095 /* Non-aware (flavored) items always come last */
6096 /* Can happen in the home */
6097 if (!object_is_aware(o_ptr)) return FALSE;
6098 if (!object_is_aware(j_ptr)) return TRUE;
6100 /* Objects sort by increasing sval */
6101 if (o_ptr->sval < j_ptr->sval) return TRUE;
6102 if (o_ptr->sval > j_ptr->sval) return FALSE;
6104 /* Unidentified objects always come last */
6105 /* Objects in the home can be unknown */
6106 if (!object_is_known(o_ptr)) return FALSE;
6107 if (!object_is_known(j_ptr)) return TRUE;
6109 /* Fixed artifacts, random artifacts and ego items */
6110 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6111 else if (o_ptr->art_name) o_type = 2;
6112 else if (object_is_ego(o_ptr)) o_type = 1;
6115 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6116 else if (j_ptr->art_name) j_type = 2;
6117 else if (object_is_ego(j_ptr)) j_type = 1;
6120 if (o_type < j_type) return TRUE;
6121 if (o_type > j_type) return FALSE;
6123 switch (o_ptr->tval)
6129 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6130 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6136 /* Objects sort by increasing hit/damage bonuses */
6137 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6138 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6141 /* Hack: otherwise identical rods sort by
6142 increasing recharge time --dsb */
6144 if (o_ptr->pval < j_ptr->pval) return TRUE;
6145 if (o_ptr->pval > j_ptr->pval) return FALSE;
6149 /* Objects sort by decreasing value */
6150 return o_value > object_value(j_ptr);
6155 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6156 * Add an item to the players inventory, and return the slot used.
6157 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6158 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6160 * If the new item can combine with an existing item in the inventory,\n
6161 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6162 * the item will be placed into the "proper" location in the inventory.\n
6164 * This function can be used to "over-fill" the player's pack, but only\n
6165 * once, and such an action must trigger the "overflow" code immediately.\n
6166 * Note that when the pack is being "over-filled", the new item must be\n
6167 * placed into the "overflow" slot, and the "overflow" must take place\n
6168 * before the pack is reordered, but (optionally) after the pack is\n
6169 * combined. This may be tricky. See "dungeon.c" for info.\n
6171 * Note that this code must remove any location/stack information\n
6172 * from the object once it is placed into the inventory.\n
6174 s16b inven_carry(object_type *o_ptr)
6176 INVENTORY_IDX i, j, k;
6177 INVENTORY_IDX n = -1;
6182 /* Check for combining */
6183 for (j = 0; j < INVEN_PACK; j++)
6185 j_ptr = &inventory[j];
6187 /* Skip non-objects */
6188 if (!j_ptr->k_idx) continue;
6190 /* Hack -- track last item */
6193 /* Check if the two items can be combined */
6194 if (object_similar(j_ptr, o_ptr))
6196 /* Combine the items */
6197 object_absorb(j_ptr, o_ptr);
6199 /* Increase the weight */
6200 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6202 /* Recalculate bonuses */
6203 p_ptr->update |= (PU_BONUS);
6206 p_ptr->window |= (PW_INVEN);
6215 if (inven_cnt > INVEN_PACK) return (-1);
6217 /* Find an empty slot */
6218 for (j = 0; j <= INVEN_PACK; j++)
6220 j_ptr = &inventory[j];
6222 /* Use it if found */
6223 if (!j_ptr->k_idx) break;
6230 /* Reorder the pack */
6233 /* Get the "value" of the item */
6234 s32b o_value = object_value(o_ptr);
6236 /* Scan every occupied slot */
6237 for (j = 0; j < INVEN_PACK; j++)
6239 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6246 for (k = n; k >= i; k--)
6248 /* Hack -- Slide the item */
6249 object_copy(&inventory[k+1], &inventory[k]);
6252 /* Wipe the empty slot */
6253 object_wipe(&inventory[i]);
6258 object_copy(&inventory[i], o_ptr);
6260 /* Access new object */
6261 j_ptr = &inventory[i];
6264 j_ptr->next_o_idx = 0;
6266 /* Forget monster */
6267 j_ptr->held_m_idx = 0;
6269 /* Forget location */
6270 j_ptr->iy = j_ptr->ix = 0;
6272 /* Player touches it, and no longer marked */
6273 j_ptr->marked = OM_TOUCHED;
6275 /* Increase the weight */
6276 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6278 /* Count the items */
6281 /* Recalculate bonuses */
6282 p_ptr->update |= (PU_BONUS);
6284 /* Combine and Reorder pack */
6285 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6288 p_ptr->window |= (PW_INVEN);
6290 /* Return the slot */
6296 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6297 * Take off (some of) a non-cursed equipment item
6298 * @param item オブジェクトを外したい所持テーブルのID
6300 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6302 * Note that only one item at a time can be wielded per slot.\n
6303 * Note that taking off an item when "full" may cause that item\n
6304 * to fall to the ground.\n
6305 * Return the inventory slot into which the item is placed.\n
6307 INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
6318 char o_name[MAX_NLEN];
6321 /* Get the item to take off */
6322 o_ptr = &inventory[item];
6325 if (amt <= 0) return (-1);
6328 if (amt > o_ptr->number) amt = o_ptr->number;
6330 /* Get local object */
6333 /* Obtain a local object */
6334 object_copy(q_ptr, o_ptr);
6336 /* Modify quantity */
6337 q_ptr->number = amt;
6339 /* Describe the object */
6340 object_desc(o_name, q_ptr, 0);
6342 /* Took off weapon */
6343 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6344 object_is_melee_weapon(o_ptr))
6346 act = _("を装備からはずした", "You were wielding");
6350 else if (item == INVEN_BOW)
6352 act = _("を装備からはずした", "You were holding");
6355 /* Took off light */
6356 else if (item == INVEN_LITE)
6358 act = _("を光源からはずした", "You were holding");
6361 /* Took off something */
6364 act = _("を装備からはずした", "You were wearing");
6367 /* Modify, Optimize */
6368 inven_item_increase(item, -amt);
6369 inven_item_optimize(item);
6371 /* Carry the object */
6372 slot = inven_carry(q_ptr);
6376 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6378 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6388 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6389 * Drop (some of) a non-cursed inventory/equipment item
6390 * @param item 所持テーブルのID
6391 * @param amt 落としたい個数
6394 * The object will be dropped "near" the current location
6396 void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
6402 char o_name[MAX_NLEN];
6405 /* Access original object */
6406 o_ptr = &inventory[item];
6409 if (amt <= 0) return;
6412 if (amt > o_ptr->number) amt = o_ptr->number;
6415 /* Take off equipment */
6416 if (item >= INVEN_RARM)
6418 /* Take off first */
6419 item = inven_takeoff(item, amt);
6421 /* Access original object */
6422 o_ptr = &inventory[item];
6426 /* Get local object */
6429 /* Obtain local object */
6430 object_copy(q_ptr, o_ptr);
6432 /* Distribute charges of wands or rods */
6433 distribute_charges(o_ptr, q_ptr, amt);
6435 /* Modify quantity */
6436 q_ptr->number = amt;
6438 /* Describe local object */
6439 object_desc(o_name, q_ptr, 0);
6442 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6444 /* Drop it near the player */
6445 (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
6447 /* Modify, Describe, Optimize */
6448 inven_item_increase(item, -amt);
6449 inven_item_describe(item);
6450 inven_item_optimize(item);
6455 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6456 * Combine items in the pack
6459 * Note special handling of the "overflow" slot
6461 void combine_pack(void)
6466 bool flag = FALSE, combined;
6472 /* Combine the pack (backwards) */
6473 for (i = INVEN_PACK; i > 0; i--)
6476 o_ptr = &inventory[i];
6478 /* Skip empty items */
6479 if (!o_ptr->k_idx) continue;
6481 /* Scan the items above that item */
6482 for (j = 0; j < i; j++)
6487 j_ptr = &inventory[j];
6489 /* Skip empty items */
6490 if (!j_ptr->k_idx) continue;
6493 * Get maximum number of the stack if these
6494 * are similar, get zero otherwise.
6496 max_num = object_similar_part(j_ptr, o_ptr);
6498 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6499 if (max_num && j_ptr->number < max_num)
6501 if (o_ptr->number + j_ptr->number <= max_num)
6506 /* Add together the item counts */
6507 object_absorb(j_ptr, o_ptr);
6509 /* One object is gone */
6512 /* Slide everything down */
6513 for (k = i; k < INVEN_PACK; k++)
6515 /* Structure copy */
6516 inventory[k] = inventory[k+1];
6519 /* Erase the "final" slot */
6520 object_wipe(&inventory[k]);
6524 int old_num = o_ptr->number;
6525 int remain = j_ptr->number + o_ptr->number - max_num;
6527 o_ptr->number -= remain;
6529 /* Add together the item counts */
6530 object_absorb(j_ptr, o_ptr);
6532 o_ptr->number = remain;
6534 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6535 if (o_ptr->tval == TV_ROD)
6537 o_ptr->pval = o_ptr->pval * remain / old_num;
6538 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6541 /* Hack -- if wands are stacking, combine the charges. -LM- */
6542 if (o_ptr->tval == TV_WAND)
6544 o_ptr->pval = o_ptr->pval * remain / old_num;
6549 p_ptr->window |= (PW_INVEN);
6563 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6567 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6568 * Reorder items in the pack
6571 * Note special handling of the "overflow" slot
6573 void reorder_pack(void)
6583 /* Re-order the pack (forwards) */
6584 for (i = 0; i < INVEN_PACK; i++)
6586 /* Mega-Hack -- allow "proper" over-flow */
6587 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6590 o_ptr = &inventory[i];
6592 /* Skip empty slots */
6593 if (!o_ptr->k_idx) continue;
6595 /* Get the "value" of the item */
6596 o_value = object_value(o_ptr);
6598 /* Scan every occupied slot */
6599 for (j = 0; j < INVEN_PACK; j++)
6601 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6604 /* Never move down */
6605 if (j >= i) continue;
6610 /* Get local object */
6613 /* Save a copy of the moving item */
6614 object_copy(q_ptr, &inventory[i]);
6616 /* Slide the objects */
6617 for (k = i; k > j; k--)
6619 /* Slide the item */
6620 object_copy(&inventory[k], &inventory[k-1]);
6623 /* Insert the moving item */
6624 object_copy(&inventory[j], q_ptr);
6627 p_ptr->window |= (PW_INVEN);
6631 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6635 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6636 * Hack -- display an object kind in the current window
6637 * @param k_idx ベースアイテムの参照ID
6640 * Include list of usable spells for readible books
6642 void display_koff(IDX k_idx)
6649 REALM_IDX use_realm;
6651 char o_name[MAX_NLEN];
6654 /* Erase the window */
6655 for (y = 0; y < Term->hgt; y++)
6657 /* Erase the line */
6658 Term_erase(0, y, 255);
6664 /* Get local object */
6667 /* Prepare the object */
6668 object_prep(q_ptr, k_idx);
6671 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6673 /* Mention the object name */
6674 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6676 /* Access the item's sval */
6678 use_realm = tval2realm(q_ptr->tval);
6680 /* Warriors are illiterate */
6681 if (p_ptr->realm1 || p_ptr->realm2)
6683 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6687 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6688 if (!is_magic(use_realm)) return;
6689 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6692 /* Display spells in readible books */
6696 SPELL_IDX spells[64];
6698 /* Extract spells */
6699 for (spell = 0; spell < 32; spell++)
6701 /* Check for this spell */
6702 if (fake_spell_flags[sval] & (1L << spell))
6704 /* Collect this spell */
6705 spells[num++] = spell;
6710 print_spells(0, spells, num, 2, 0, use_realm);
6715 * @brief 警告を放つアイテムを選択する /
6716 * Choose one of items that have warning flag
6717 * Calculate spell damages
6720 object_type *choose_warning_item(void)
6723 int choices[INVEN_TOTAL - INVEN_RARM];
6726 /* Paranoia -- Player has no warning ability */
6727 if (!p_ptr->warning) return NULL;
6729 /* Search Inventory */
6730 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6732 u32b flgs[TR_FLAG_SIZE];
6733 object_type *o_ptr = &inventory[i];
6735 object_flags(o_ptr, flgs);
6736 if (have_flag(flgs, TR_WARNING))
6738 choices[number] = i;
6743 /* Choice one of them */
6744 return number ? &inventory[choices[randint0(number)]] : NULL;
6748 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6749 * Calculate spell damages
6750 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6751 * @param typ 効果属性のID
6753 * @param max 算出した最大ダメージを返すポインタ
6756 static void spell_damcalc(monster_type *m_ptr, int typ, HIT_POINT dam, int *max)
6758 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6759 int rlev = r_ptr->level;
6760 bool ignore_wraith_form = FALSE;
6762 /* Vulnerability, resistance and immunity */
6766 if (p_ptr->immune_elec)
6769 ignore_wraith_form = TRUE;
6773 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6774 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6775 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6776 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6777 if (IS_OPPOSE_ELEC())
6778 dam = (dam + 2) / 3;
6783 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6784 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6788 if (p_ptr->immune_acid)
6791 ignore_wraith_form = TRUE;
6795 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6796 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6797 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6798 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6804 if (p_ptr->immune_cold)
6807 ignore_wraith_form = TRUE;
6811 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6812 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6813 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6814 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6819 if (p_ptr->immune_fire)
6822 ignore_wraith_form = TRUE;
6826 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6827 if (prace_is_(RACE_ENT)) dam += dam / 3;
6828 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6829 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6830 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6835 ignore_wraith_form = TRUE;
6839 if (!p_ptr->blind &&
6840 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6841 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6844 ignore_wraith_form = TRUE;
6849 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6850 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6851 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6854 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6855 * "dam *= 2;" for later "dam /= 2"
6857 if (p_ptr->wraith_form) dam *= 2;
6861 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6864 ignore_wraith_form = TRUE;
6866 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6870 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6874 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6878 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6882 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6886 if (prace_is_(RACE_SPECTRE))
6889 ignore_wraith_form = TRUE;
6891 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6895 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6899 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6903 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6907 if (p_ptr->levitation) dam = (dam * 2) / 3;
6911 if (p_ptr->resist_shard) dam /= 2;
6915 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6916 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6920 if (p_ptr->mimic_form)
6922 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6925 ignore_wraith_form = TRUE;
6930 switch (p_ptr->prace)
6939 ignore_wraith_form = TRUE;
6946 if (p_ptr->align > 10) dam /= 2;
6947 else if (p_ptr->align < -10) dam *= 2;
6951 if (p_ptr->align > 10) dam *= 2;
6955 case GF_BRAIN_SMASH:
6956 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6959 ignore_wraith_form = TRUE;
6967 if (100 + rlev / 2 <= p_ptr->skill_sav)
6970 ignore_wraith_form = TRUE;
6975 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6978 ignore_wraith_form = TRUE;
6983 if (p_ptr->wraith_form && !ignore_wraith_form)
6989 if (dam > *max) *max = dam;
6993 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6994 * Calculate spell damages
6995 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6996 * @param typ 効果属性のID
6997 * @param m_idx 魔法を行使するモンスターのID
6998 * @param max 算出した最大ダメージを返すポインタ
7001 void spell_damcalc_by_spellnum(int spell_num, int typ, MONSTER_IDX m_idx, int *max)
7003 monster_type *m_ptr = &m_list[m_idx];
7004 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
7005 spell_damcalc(m_ptr, typ, dam, max);
7009 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
7010 * Calculate blow damages
7011 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
7012 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
7013 * @return 算出された最大ダメージを返す。
7015 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7017 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7019 bool check_wraith_form = TRUE;
7021 if (blow_ptr->method != RBM_EXPLODE)
7023 int ac = p_ptr->ac + p_ptr->to_a;
7025 switch (blow_ptr->effect)
7029 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7030 dam = MAX(dam, tmp_dam * 2);
7036 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7040 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7042 check_wraith_form = FALSE;
7046 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7048 check_wraith_form = FALSE;
7052 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7054 check_wraith_form = FALSE;
7058 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7060 check_wraith_form = FALSE;
7065 check_wraith_form = FALSE;
7069 if (check_wraith_form && p_ptr->wraith_form)
7077 dam = (dam + 1) / 2;
7078 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7086 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7087 * Examine the grid (xx,yy) and warn the player if there are any danger
7088 * @param xx 危険性を調査するマスのX座標
7089 * @param yy 危険性を調査するマスのY座標
7090 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7092 bool process_warning(int xx, int yy)
7096 char o_name[MAX_NLEN];
7098 #define WARNING_AWARE_RANGE 12
7100 static int old_damage = 0;
7102 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7104 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7107 monster_type *m_ptr;
7108 monster_race *r_ptr;
7110 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7112 c_ptr = &cave[my][mx];
7114 if (!c_ptr->m_idx) continue;
7116 m_ptr = &m_list[c_ptr->m_idx];
7118 if (MON_CSLEEP(m_ptr)) continue;
7119 if (!is_hostile(m_ptr)) continue;
7121 r_ptr = &r_info[m_ptr->r_idx];
7123 /* Monster spells (only powerful ones)*/
7124 if (projectable(my, mx, yy, xx))
7126 u32b f4 = r_ptr->flags4;
7127 u32b f5 = r_ptr->a_ability_flags1;
7128 u32b f6 = r_ptr->a_ability_flags2;
7130 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7132 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7133 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7134 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7135 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7136 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7137 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7139 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7140 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7141 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7142 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7143 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7144 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7145 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7146 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7147 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7148 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7149 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7150 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7151 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7152 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7153 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7154 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
7155 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7156 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7157 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7158 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7159 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7160 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7161 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7164 /* Monster melee attacks */
7165 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7167 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7171 for (m = 0; m < 4; m++)
7173 /* Skip non-attacks */
7174 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7176 /* Extract the attack info */
7177 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7178 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7180 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7184 /* Contribution from this monster */
7185 dam_max += dam_max0;
7189 /* Prevent excessive warning */
7190 if (dam_max > old_damage)
7192 old_damage = dam_max * 3 / 2;
7194 if (dam_max > p_ptr->chp / 2)
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);
7205 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7208 else old_damage = old_damage / 2;
7210 c_ptr = &cave[yy][xx];
7211 if (((!easy_disarm && is_trap(c_ptr->feat))
7212 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7214 object_type *o_ptr = choose_warning_item();
7217 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7219 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7220 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7222 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7229 * エッセンス情報の構造体 / A structure for smithing
7232 int add; /* TR flag number or special essence id */
7233 cptr add_name; /* Name of this ability */
7234 ESSENCE_IDX type; /* Menu number */
7235 int essence; /* Index for carrying essences */
7236 int value; /* Needed value to add this ability */
7241 * エッセンス情報テーブル Smithing type data for Weapon smith
7244 static essence_type essence_info[] =
7246 {TR_STR, "腕力", 4, TR_STR, 20},
7247 {TR_INT, "知能", 4, TR_INT, 20},
7248 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7249 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7250 {TR_CON, "耐久力", 4, TR_CON, 20},
7251 {TR_CHR, "魅力", 4, TR_CHR, 20},
7252 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7253 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7254 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7255 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7256 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7257 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7258 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7259 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7260 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7261 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7262 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7263 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7264 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7265 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7266 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7267 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7268 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7269 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7270 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7271 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7272 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7273 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7274 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7275 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7276 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7277 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7278 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7279 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7280 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7281 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7282 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7283 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7284 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7285 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7286 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7287 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7288 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7289 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7290 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7291 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7292 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7293 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7294 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7295 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7296 {TR_SH_FIRE, "", 0, -2, 0},
7297 {TR_SH_ELEC, "", 0, -2, 0},
7298 {TR_SH_COLD, "", 0, -2, 0},
7299 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7300 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7301 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7302 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7303 {TR_LITE_2, "", 0, -2, 0},
7304 {TR_LITE_3, "", 0, -2, 0},
7305 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7306 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7307 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7308 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7309 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7311 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7312 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7313 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7314 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7315 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7316 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7317 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7318 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7319 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7320 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7321 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7322 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7323 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7324 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7325 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7326 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7327 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7328 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7330 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7331 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7332 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7333 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7334 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7335 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7336 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7337 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7339 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7340 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7341 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7342 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7343 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7344 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7345 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7346 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7347 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7348 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7349 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7350 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7352 {-1, NULL, 0, -1, 0}
7355 static essence_type essence_info[] =
7357 {TR_STR, "strength", 4, TR_STR, 20},
7358 {TR_INT, "intelligence", 4, TR_INT, 20},
7359 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7360 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7361 {TR_CON, "constitution", 4, TR_CON, 20},
7362 {TR_CHR, "charisma", 4, TR_CHR, 20},
7363 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7364 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7365 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7366 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7367 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7368 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7369 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7370 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7371 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7372 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7373 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7374 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7375 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7376 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7377 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7378 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7379 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7380 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7381 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7382 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7383 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7384 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7385 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7386 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7387 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7388 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7389 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7390 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7391 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7392 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7393 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7394 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7395 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7396 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7397 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7398 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7399 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7400 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7401 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7402 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7403 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7404 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7405 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7406 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7407 {TR_SH_FIRE, "", 0, -2, 0},
7408 {TR_SH_ELEC, "", 0, -2, 0},
7409 {TR_SH_COLD, "", 0, -2, 0},
7410 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7411 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7412 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7413 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7414 {TR_LITE_2, "", 0, -2, 0},
7415 {TR_LITE_3, "", 0, -2, 0},
7416 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7417 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7418 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7419 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7420 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7422 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7423 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7424 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7425 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7426 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7427 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7428 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7429 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7430 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7431 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7432 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7433 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7434 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7435 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7436 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7437 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7438 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7439 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7441 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7442 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7443 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7444 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7445 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7446 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7447 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7448 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7450 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7451 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7452 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7453 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7454 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7455 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7456 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7457 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7458 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7459 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7460 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7461 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7463 {-1, NULL, 0, -1, 0}
7469 * エッセンス名テーブル / Essense names for Weapon smith
7472 cptr essence_name[] =
7575 cptr essence_name[] =
7678 * @brief 所持しているエッセンス一覧を表示する
7681 static void display_essence(void)
7686 for (i = 1; i < 22; i++)
7690 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7691 "Essence Num Essence Num Essence Num "), 1, 8);
7692 for (i = 0; essence_name[i]; i++)
7694 if (!essence_name[i][0]) continue;
7695 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7698 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7708 static void drain_essence(void)
7710 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7714 bool observe = FALSE;
7715 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
7716 TIME_EFFECT old_timeout;
7717 BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7723 OBJECT_IDX next_o_idx;
7726 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7729 item_tester_hook = object_is_weapon_armour_ammo;
7730 item_tester_no_ryoute = TRUE;
7733 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7734 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7736 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7738 /* Get the item (in the pack) */
7741 o_ptr = &inventory[item];
7744 /* Get the item (on the floor) */
7747 o_ptr = &o_list[0 - item];
7750 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7752 char o_name[MAX_NLEN];
7753 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7754 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7757 p_ptr->energy_use = 100;
7759 object_flags(o_ptr, old_flgs);
7760 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7761 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7762 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7763 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7764 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7765 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7766 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7767 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7768 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7770 old_to_a = o_ptr->to_a;
7772 old_to_h = o_ptr->to_h;
7773 old_to_d = o_ptr->to_d;
7776 old_pval = o_ptr->pval;
7777 old_name2 = o_ptr->name2;
7778 old_timeout = o_ptr->timeout;
7779 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7780 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7781 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7782 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7783 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7784 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7785 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7786 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7787 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7788 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7789 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7790 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7791 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7792 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7793 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7794 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7795 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7796 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7797 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7801 next_o_idx = o_ptr->next_o_idx;
7802 marked = o_ptr->marked;
7803 weight = o_ptr->weight;
7804 number = o_ptr->number;
7806 object_prep(o_ptr, o_ptr->k_idx);
7810 o_ptr->next_o_idx=next_o_idx;
7811 o_ptr->marked=marked;
7812 o_ptr->number = number;
7813 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7814 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7815 o_ptr->ident |= (IDENT_MENTAL);
7816 object_aware(o_ptr);
7817 object_known(o_ptr);
7819 object_flags(o_ptr, new_flgs);
7821 for (i = 0; essence_info[i].add_name; i++)
7823 essence_type *es_ptr = &essence_info[i];
7824 PARAMETER_VALUE pval = 0;
7826 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7827 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7829 if (es_ptr->add < TR_FLAG_MAX &&
7830 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7831 have_flag(old_flgs, es_ptr->add))
7835 drain_value[es_ptr->essence] += 10 * pval;
7837 else if (es_ptr->essence != -2)
7839 drain_value[es_ptr->essence] += 10;
7841 else if (es_ptr->add == TR_SH_FIRE)
7843 drain_value[TR_BRAND_FIRE] += 10;
7844 drain_value[TR_RES_FIRE] += 10;
7846 else if (es_ptr->add == TR_SH_ELEC)
7848 drain_value[TR_BRAND_ELEC] += 10;
7849 drain_value[TR_RES_ELEC] += 10;
7851 else if (es_ptr->add == TR_SH_COLD)
7853 drain_value[TR_BRAND_COLD] += 10;
7854 drain_value[TR_RES_COLD] += 10;
7856 else if (es_ptr->add == TR_LITE_2)
7858 drain_value[TR_LITE_1] += 20;
7860 else if (es_ptr->add == TR_LITE_3)
7862 drain_value[TR_LITE_1] += 30;
7867 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7869 drain_value[TR_INT] += 5;
7870 drain_value[TR_WIS] += 5;
7872 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7874 drain_value[TR_BRAND_POIS] += 5;
7875 drain_value[TR_BRAND_ACID] += 5;
7876 drain_value[TR_BRAND_ELEC] += 5;
7877 drain_value[TR_BRAND_FIRE] += 5;
7878 drain_value[TR_BRAND_COLD] += 5;
7880 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7882 drain_value[TR_INT] += 10;
7884 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7886 drain_value[TR_STR] += 10;
7888 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7890 drain_value[TR_DEX] += 10;
7892 if (old_name2 == EGO_2WEAPON)
7894 drain_value[TR_DEX] += 20;
7896 if (object_is_weapon_ammo(o_ptr))
7898 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7900 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7902 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7903 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7904 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7905 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7907 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7909 drain_value[i] *= number;
7910 drain_value[i] = drain_value[i] * dec / 4;
7911 drain_value[i] = MAX(drain_value[i], 0);
7912 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7920 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7924 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7926 for (i = 0; essence_name[i]; i++)
7928 if (!essence_name[i][0]) continue;
7929 if (!drain_value[i]) continue;
7931 p_ptr->magic_num1[i] += drain_value[i];
7932 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7934 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7938 /* Apply autodestroy/inscription to the drained item */
7939 autopick_alter_item(item, TRUE);
7941 /* Combine the pack */
7942 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7945 p_ptr->window |= (PW_INVEN);
7949 * @brief 付加するエッセンスの大別を選択する
7950 * @return 選んだエッセンスの大別ID
7952 static COMMAND_CODE choose_essence(void)
7954 COMMAND_CODE mode = 0;
7956 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
7959 cptr menu_name[] = {
7969 cptr menu_name[] = {
7979 const COMMAND_CODE mode_max = 7;
7982 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
7985 #endif /* ALLOW_REPEAT */
7994 for (i = 0; i < mode_max; i++)
7996 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
7997 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
7999 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8000 prt("Choose from menu.", 0, 0);
8019 menu_line += mode_max - 1;
8028 if (menu_line > mode_max) menu_line -= mode_max;
8039 for (i = 0; i < mode_max; i++)
8040 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8042 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8048 if (isupper(choice)) choice = (char)tolower(choice);
8050 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8051 mode = (int)choice - 'a' + 1;
8058 #endif /* ALLOW_REPEAT */
8063 * @brief エッセンスを実際に付加する
8064 * @param mode エッセンスの大別ID
8067 static void add_essence(ESSENCE_IDX mode)
8079 char o_name[MAX_NLEN];
8081 essence_type *es_ptr;
8082 bool able[22] = { 0 };
8084 int menu_line = (use_menu ? 1 : 0);
8086 for (i = 0; essence_info[i].add_name; i++)
8088 es_ptr = &essence_info[i];
8090 if (es_ptr->type != mode) continue;
8095 if (!repeat_pull(&i) || i<0 || i>=max_num)
8097 #endif /* ALLOW_REPEAT */
8100 /* Nothing chosen yet */
8106 /* Build a prompt */
8107 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8108 if (use_menu) screen_save();
8110 /* Get a spell from the user */
8112 choice = (always_show_list || use_menu) ? ESCAPE:1;
8115 if( choice==ESCAPE ) choice = ' ';
8116 else if( !get_com(out_val, &choice, FALSE) )break;
8118 if (use_menu && choice != ' ')
8132 menu_line += (max_num-1);
8155 menu_line = max_num;
8169 if (menu_line > max_num) menu_line -= max_num;
8171 /* Request redraw */
8172 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8175 if (!redraw || use_menu)
8179 char dummy[80], dummy2[80];
8187 /* Save the screen */
8188 if (!use_menu) screen_save();
8190 for (y = 1; y < 24; y++)
8193 /* Print header(s) */
8195 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8198 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8201 for (ctr = 0; ctr < max_num; ctr++)
8203 es_ptr = &essence_info[num[ctr]];
8207 if (ctr == (menu_line-1))
8208 strcpy(dummy, _("》 ", "> "));
8209 else strcpy(dummy, " ");
8212 /* letter/number for power selection */
8215 sprintf(dummy, "%c) ",I2A(ctr));
8218 strcat(dummy, es_ptr->add_name);
8223 if (es_ptr->essence != -1)
8225 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8226 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8232 case ESSENCE_SH_FIRE:
8233 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8234 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8235 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8237 case ESSENCE_SH_ELEC:
8238 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8239 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8240 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8242 case ESSENCE_SH_COLD:
8243 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8244 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8245 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8247 case ESSENCE_RESISTANCE:
8248 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8249 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8250 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8251 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8252 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8254 case ESSENCE_SUSTAIN:
8255 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8256 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8257 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8258 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8259 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8264 if (!able[ctr]) col = TERM_RED;
8266 if (es_ptr->essence != -1)
8268 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8272 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8275 c_prt(col, dummy2, ctr+2, x);
8285 /* Restore the screen */
8296 ask = (isupper(choice));
8299 if (ask) choice = (char)tolower(choice);
8301 /* Extract request */
8302 i = (islower(choice) ? A2I(choice) : -1);
8305 /* Totally Illegal */
8306 if ((i < 0) || (i >= max_num) || !able[i])
8318 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8320 /* Belay that order */
8321 if (!get_check(tmp_val)) continue;
8328 /* Restore the screen */
8329 if (redraw) screen_load();
8336 #endif /* ALLOW_REPEAT */
8338 es_ptr = &essence_info[num[i]];
8340 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8341 item_tester_tval = TV_GLOVES;
8342 else if (mode == 1 || mode == 5)
8343 item_tester_hook = item_tester_hook_melee_ammo;
8344 else if (es_ptr->add == ESSENCE_ATTACK)
8345 item_tester_hook = object_allow_enchant_weapon;
8346 else if (es_ptr->add == ESSENCE_AC)
8347 item_tester_hook = object_is_armour;
8349 item_tester_hook = object_is_weapon_armour_ammo;
8350 item_tester_no_ryoute = TRUE;
8353 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8354 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8356 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8358 /* Get the item (in the pack) */
8361 o_ptr = &inventory[item];
8364 /* Get the item (on the floor) */
8367 o_ptr = &o_list[0 - item];
8370 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8372 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8376 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8378 use_essence = es_ptr->value;
8379 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8380 if (o_ptr->number > 1)
8382 use_essence *= o_ptr->number;
8383 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8386 if (es_ptr->essence != -1)
8388 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8390 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8393 if (is_pval_flag(es_ptr->add))
8395 if (o_ptr->pval < 0)
8397 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8400 else if (es_ptr->add == TR_BLOWS)
8402 if (o_ptr->pval > 1)
8404 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8408 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8410 else if (o_ptr->pval > 0)
8412 use_essence *= o_ptr->pval;
8413 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8419 PARAMETER_VALUE pval;
8420 PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8422 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8423 strcpy(tmp_val, "1");
8425 if (!get_string(tmp, tmp_val, 1)) return;
8426 pval = (PARAMETER_VALUE)atoi(tmp_val);
8427 if (pval > limit) pval = limit;
8428 else if (pval < 1) pval = 1;
8429 o_ptr->pval += pval;
8430 use_essence *= pval;
8431 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8434 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8436 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8440 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8447 strcpy(tmp_val, "1");
8448 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8449 val = atoi(tmp_val);
8450 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8451 else if (val < 1) val = 1;
8453 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8454 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8456 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8459 get_to_h = ((val+1)/2+randint0(val/2+1));
8460 get_to_d = ((val+1)/2+randint0(val/2+1));
8461 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8462 o_ptr->to_h += get_to_h;
8463 o_ptr->to_d += get_to_d;
8465 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8466 if (es_ptr->add == ESSENCE_ATTACK)
8468 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8470 msg_print(_("改良に失敗した。", "You failed to enchant."));
8471 p_ptr->energy_use = 100;
8476 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8477 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8480 else if (es_ptr->add == ESSENCE_AC)
8482 if (o_ptr->to_a >= p_ptr->lev/5+5)
8484 msg_print(_("改良に失敗した。", "You failed to enchant."));
8485 p_ptr->energy_use = 100;
8490 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8495 o_ptr->xtra3 = es_ptr->add + 1;
8500 bool success = TRUE;
8504 case ESSENCE_SH_FIRE:
8505 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8510 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8511 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8513 case ESSENCE_SH_ELEC:
8514 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8519 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8520 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8522 case ESSENCE_SH_COLD:
8523 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8528 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8529 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8531 case ESSENCE_RESISTANCE:
8532 case ESSENCE_SUSTAIN:
8533 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))
8538 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8539 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8540 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8541 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8546 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8549 if (es_ptr->add == ESSENCE_SUSTAIN)
8551 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8552 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8553 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8554 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8558 o_ptr->xtra3 = es_ptr->add + 1;
8562 p_ptr->energy_use = 100;
8565 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8567 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8570 /* Combine the pack */
8571 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8574 p_ptr->window |= (PW_INVEN);
8581 static void erase_essence(void)
8586 char o_name[MAX_NLEN];
8587 BIT_FLAGS flgs[TR_FLAG_SIZE];
8589 item_tester_hook = object_is_smith;
8592 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8593 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8595 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8597 /* Get the item (in the pack) */
8600 o_ptr = &inventory[item];
8603 /* Get the item (on the floor) */
8606 o_ptr = &o_list[0 - item];
8609 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8610 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8612 p_ptr->energy_use = 100;
8614 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8616 o_ptr->to_h -= (o_ptr->xtra4>>8);
8617 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8619 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8620 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8623 object_flags(o_ptr, flgs);
8624 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8625 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8627 /* Combine the pack */
8628 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8631 p_ptr->window |= (PW_INVEN);
8635 * @brief 鍛冶コマンドのメインルーチン
8636 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8639 void do_cmd_kaji(bool only_browse)
8641 COMMAND_CODE mode = 0;
8644 COMMAND_CODE menu_line = (use_menu ? 1 : 0);
8648 if (p_ptr->confused)
8650 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8655 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8660 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8666 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8668 #endif /* ALLOW_REPEAT */
8670 if (only_browse) screen_save();
8672 if (!only_browse) screen_save();
8678 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8679 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8680 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8681 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8682 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8683 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8685 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8686 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8687 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8688 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8689 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8690 prt(format("Choose command from menu."), 0, 0);
8717 if (menu_line > 5) menu_line -= 5;
8726 prt(" a) エッセンス一覧", 2, 14);
8727 prt(" b) エッセンス抽出", 3, 14);
8728 prt(" c) エッセンス消去", 4, 14);
8729 prt(" d) エッセンス付加", 5, 14);
8730 prt(" e) 武器/防具強化", 6, 14);
8731 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8733 prt(" a) List essences", 2, 14);
8734 prt(" b) Extract essence", 3, 14);
8735 prt(" c) Remove essence", 4, 14);
8736 prt(" d) Add essence", 5, 14);
8737 prt(" e) Enchant weapon/armor", 6, 14);
8738 if (!get_com("Command :", &choice, TRUE))
8775 /* Clear lines, position cursor (really should use strlen here) */
8776 Term_erase(14, 21, 255);
8777 Term_erase(14, 20, 255);
8778 Term_erase(14, 19, 255);
8779 Term_erase(14, 18, 255);
8780 Term_erase(14, 17, 255);
8781 Term_erase(14, 16, 255);
8783 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8784 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8786 prt(&temp[j], line, 15);
8791 if (!only_browse) screen_load();
8792 } while (only_browse);
8796 #endif /* ALLOW_REPEAT */
8800 case 1: display_essence();break;
8801 case 2: drain_essence();break;
8802 case 3: erase_essence();break;
8804 mode = choose_essence();
8809 case 5: add_essence(10);break;
8815 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8816 * Torches have special abilities when they are flaming.
8817 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8818 * @param flgs 特別に追加するフラグを返す参照ポインタ
8821 void torch_flags(object_type *o_ptr, u32b *flgs)
8823 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8825 if (o_ptr->xtra4 > 0)
8827 add_flag(flgs, TR_BRAND_FIRE);
8828 add_flag(flgs, TR_KILL_UNDEAD);
8829 add_flag(flgs, TR_THROW);
8835 * @brief 投擲時たいまつにダイスを与える。
8836 * Torches have special abilities when they are flaming.
8837 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8838 * @param dd 特別なダイス数を返す参照ポインタ
8839 * @param ds 特別なダイス面数を返す参照ポインタ
8842 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8844 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8846 if (o_ptr->xtra4 > 0)
8855 * @brief 投擲時命中したたいまつの寿命を縮める。
8856 * Torches have special abilities when they are flaming.
8857 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8860 void torch_lost_fuel(object_type *o_ptr)
8862 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8864 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8865 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;