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
19 * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
20 * @param o_idx 削除対象のオブジェクト構造体ポインタ
23 void excise_object_idx(int o_idx)
27 s16b this_o_idx, next_o_idx = 0;
33 j_ptr = &o_list[o_idx];
36 if (j_ptr->held_m_idx)
41 m_ptr = &m_list[j_ptr->held_m_idx];
43 /* Scan all objects in the grid */
44 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
49 o_ptr = &o_list[this_o_idx];
51 /* Acquire next object */
52 next_o_idx = o_ptr->next_o_idx;
55 if (this_o_idx == o_idx)
60 /* Remove from list */
61 m_ptr->hold_o_idx = next_o_idx;
70 k_ptr = &o_list[prev_o_idx];
72 /* Remove from list */
73 k_ptr->next_o_idx = next_o_idx;
76 /* Forget next pointer */
77 o_ptr->next_o_idx = 0;
84 prev_o_idx = this_o_idx;
99 /* Scan all objects in the grid */
100 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
105 o_ptr = &o_list[this_o_idx];
107 /* Acquire next object */
108 next_o_idx = o_ptr->next_o_idx;
111 if (this_o_idx == o_idx)
116 /* Remove from list */
117 c_ptr->o_idx = next_o_idx;
125 /* Previous object */
126 k_ptr = &o_list[prev_o_idx];
128 /* Remove from list */
129 k_ptr->next_o_idx = next_o_idx;
132 /* Forget next pointer */
133 o_ptr->next_o_idx = 0;
139 /* Save prev_o_idx */
140 prev_o_idx = this_o_idx;
146 * @brief オブジェクトを削除する /
147 * Delete a dungeon object
148 * @param o_idx 削除対象のオブジェクト構造体ポインタ
151 * Handle "stacks" of objects correctly.
153 void delete_object_idx(int o_idx)
158 excise_object_idx(o_idx);
161 j_ptr = &o_list[o_idx];
164 if (!(j_ptr->held_m_idx))
176 /* Wipe the object */
185 * @brief フロアにマスに落ちているオブジェクトを全て削除する / Deletes all objects at given location
186 * Delete a dungeon object
187 * @param y 削除したフロアマスのY座標
188 * @param x 削除したフロアマスのX座標
191 void delete_object(int y, int x)
195 s16b this_o_idx, next_o_idx = 0;
198 /* Refuse "illegal" locations */
199 if (!in_bounds(y, x)) return;
205 /* Scan all objects in the grid */
206 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
211 o_ptr = &o_list[this_o_idx];
213 /* Acquire next object */
214 next_o_idx = o_ptr->next_o_idx;
216 /* Wipe the object */
223 /* Objects are gone */
232 * @brief グローバルオブジェクト配列に対し指定範囲のオブジェクトを整理してIDの若い順に寄せる /
233 * Move an object from index i1 to index i2 in the object list
234 * @param i1 整理したい配列の始点
235 * @param i2 整理したい配列の終点
238 static void compact_objects_aux(int i1, int i2)
248 if (i1 == i2) return;
252 for (i = 1; i < o_max; i++)
257 /* Skip "dead" objects */
258 if (!o_ptr->k_idx) continue;
260 /* Repair "next" pointers */
261 if (o_ptr->next_o_idx == i1)
264 o_ptr->next_o_idx = i2;
274 if (o_ptr->held_m_idx)
278 /* Acquire monster */
279 m_ptr = &m_list[o_ptr->held_m_idx];
282 if (m_ptr->hold_o_idx == i1)
285 m_ptr->hold_o_idx = i2;
294 /* Acquire location */
302 if (c_ptr->o_idx == i1)
311 o_list[i2] = o_list[i1];
319 * @brief グローバルオブジェクト配列から優先度の低いものを削除し、データを圧縮する。 /
320 * Compact and Reorder the object list.
321 * @param size 最低でも減らしたいオブジェクト数の水準
325 * This function can be very dangerous, use with caution!\n
327 * When actually "compacting" objects, we base the saving throw on a\n
328 * combination of object level, distance from player, and current\n
331 * After "compacting" (if needed), we "reorder" the objects into a more\n
332 * compact order, and we reset the allocation info, and the "live" array.\n
334 void compact_objects(int size)
336 int i, y, x, num, cnt;
337 int cur_lev, cur_dis, chance;
345 msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
348 p_ptr->redraw |= (PR_MAP);
351 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
355 /* Compact at least 'size' objects */
356 for (num = 0, cnt = 1; num < size; cnt++)
358 /* Get more vicious each iteration */
361 /* Get closer each iteration */
362 cur_dis = 5 * (20 - cnt);
364 /* Examine the objects */
365 for (i = 1; i < o_max; i++)
369 /* Skip dead objects */
370 if (!o_ptr->k_idx) continue;
372 /* Hack -- High level objects start out "immune" */
373 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
376 if (o_ptr->held_m_idx)
380 /* Acquire monster */
381 m_ptr = &m_list[o_ptr->held_m_idx];
383 /* Get the location */
387 /* Monsters protect their objects */
388 if (randint0(100) < 90) continue;
394 /* Get the location */
399 /* Nearby objects start out "immune" */
400 if ((cur_dis > 0) && (distance(py, px, y, x) < cur_dis)) continue;
405 /* Hack -- only compact artifacts in emergencies */
406 if ((object_is_fixed_artifact(o_ptr) || o_ptr->art_name) &&
407 (cnt < 1000)) chance = 100;
409 /* Apply the saving throw */
410 if (randint0(100) < chance) continue;
412 /* Delete the object */
413 delete_object_idx(i);
421 /* Excise dead objects (backwards!) */
422 for (i = o_max - 1; i >= 1; i--)
426 /* Skip real objects */
427 if (o_ptr->k_idx) continue;
429 /* Move last object into open hole */
430 compact_objects_aux(o_max - 1, i);
432 /* Compress "o_max" */
439 * @brief グローバルオブジェクト配列を初期化する /
440 * Delete all the items when player leaves the level
441 * @note we do NOT visually reflect these (irrelevant) changes
443 * Hack -- we clear the "c_ptr->o_idx" field for every grid,
444 * and the "m_ptr->next_o_idx" field for every monster, since
445 * we know we are clearing every object. Technically, we only
446 * clear those fields for grids/monsters containing objects,
447 * and we clear it once for every such object.
450 void wipe_o_list(void)
454 /* Delete the existing objects */
455 for (i = 1; i < o_max; i++)
457 object_type *o_ptr = &o_list[i];
459 /* Skip dead objects */
460 if (!o_ptr->k_idx) continue;
462 /* Mega-Hack -- preserve artifacts */
463 if (!character_dungeon || preserve_mode)
465 /* Hack -- Preserve unknown artifacts */
466 if (object_is_fixed_artifact(o_ptr) && !object_is_known(o_ptr))
468 /* Mega-Hack -- Preserve the artifact */
469 a_info[o_ptr->name1].cur_num = 0;
474 if (o_ptr->held_m_idx)
479 m_ptr = &m_list[o_ptr->held_m_idx];
481 /* Hack -- see above */
482 m_ptr->hold_o_idx = 0;
490 /* Access location */
497 /* Hack -- see above */
501 /* Wipe the object */
514 * @brief グローバルオブジェクト配列から空きを取得する /
515 * Acquires and returns the index of a "free" object.
516 * @return 開いているオブジェクト要素のID
518 * This routine should almost never fail, but in case it does,
519 * we must be sure to handle "failure" of this routine.
526 /* Initial allocation */
527 if (o_max < max_o_idx)
532 /* Expand object array */
538 /* Use this object */
543 /* Recycle dead objects */
544 for (i = 1; i < o_max; i++)
551 /* Skip live objects */
552 if (o_ptr->k_idx) continue;
557 /* Use this object */
562 /* Warn the player (except during dungeon creation) */
563 if (character_dungeon) msg_print(_("アイテムが多すぎる!", "Too many objects!"));
571 * @brief オブジェクト生成テーブルに生成制約を加える /
572 * Apply a "object restriction function" to the "object allocation table"
574 * @details 生成の制約はグローバルのget_obj_num_hook関数ポインタで加える
576 static errr get_obj_num_prep(void)
581 alloc_entry *table = alloc_kind_table;
583 /* Scan the allocation table */
584 for (i = 0; i < alloc_kind_size; i++)
586 /* Accept objects which pass the restriction, if any */
587 if (!get_obj_num_hook || (*get_obj_num_hook)(table[i].index))
589 /* Accept this object */
590 table[i].prob2 = table[i].prob1;
593 /* Do not use this object */
596 /* Decline this object */
607 * @brief オブジェクト生成テーブルからアイテムを取得する /
608 * Choose an object kind that seems "appropriate" to the given level
610 * @return 選ばれたオブジェクトベースID
612 * This function uses the "prob2" field of the "object allocation table",\n
613 * and various local information, to calculate the "prob3" field of the\n
614 * same table, which is then used to choose an "appropriate" object, in\n
615 * a relatively efficient manner.\n
617 * It is (slightly) more likely to acquire an object of the given level\n
618 * than one of a lower level. This is done by choosing several objects\n
619 * appropriate to the given level and keeping the "hardest" one.\n
621 * Note that if no objects are "appropriate", then this function will\n
622 * fail, and return zero, but this should *almost* never happen.\n
624 s16b get_obj_num(int level)
630 alloc_entry *table = alloc_kind_table;
632 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
635 if ((level > 0) && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
637 /* Occasional "boost" */
638 if (one_in_(GREAT_OBJ))
640 /* What a bizarre calculation */
641 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
648 /* Process probabilities */
649 for (i = 0; i < alloc_kind_size; i++)
651 /* Objects are sorted by depth */
652 if (table[i].level > level) break;
657 /* Access the index */
658 k_idx = table[i].index;
660 /* Access the actual kind */
661 k_ptr = &k_info[k_idx];
663 /* Hack -- prevent embedded chests */
664 if (opening_chest && (k_ptr->tval == TV_CHEST)) continue;
667 table[i].prob3 = table[i].prob2;
670 total += table[i].prob3;
673 /* No legal objects */
674 if (total <= 0) return (0);
678 value = randint0(total);
680 /* Find the object */
681 for (i = 0; i < alloc_kind_size; i++)
683 /* Found the entry */
684 if (value < table[i].prob3) break;
687 value = value - table[i].prob3;
694 /* Try for a "better" object once (50%) or twice (10%) */
701 value = randint0(total);
703 /* Find the object */
704 for (i = 0; i < alloc_kind_size; i++)
706 /* Found the entry */
707 if (value < table[i].prob3) break;
710 value = value - table[i].prob3;
713 /* Keep the "best" one */
714 if (table[i].level < table[j].level) i = j;
717 /* Try for a "better" object twice (10%) */
724 value = randint0(total);
726 /* Find the object */
727 for (i = 0; i < alloc_kind_size; i++)
729 /* Found the entry */
730 if (value < table[i].prob3) break;
733 value = value - table[i].prob3;
736 /* Keep the "best" one */
737 if (table[i].level < table[j].level) i = j;
742 return (table[i].index);
747 * @brief オブジェクトを鑑定済にする /
748 * Known is true when the "attributes" of an object are "known".
749 * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
751 * These include tohit, todam, toac, cost, and pval (charges).\n
753 * Note that "knowing" an object gives you everything that an "awareness"\n
754 * gives you, and much more. In fact, the player is always "aware" of any\n
755 * item of which he has full "knowledge".\n
757 * But having full knowledge of, say, one "wand of wonder", does not, by\n
758 * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
759 * It happens that most "identify" routines (including "buying from a shop")\n
760 * will make the player "aware" of the object as well as fully "know" it.\n
762 * This routine also removes any inscriptions generated by "feelings".\n
764 void object_known(object_type *o_ptr)
766 /* Remove "default inscriptions" */
767 o_ptr->feeling = FEEL_NONE;
769 /* Clear the "Felt" info */
770 o_ptr->ident &= ~(IDENT_SENSE);
772 /* Clear the "Empty" info */
773 o_ptr->ident &= ~(IDENT_EMPTY);
775 /* Now we know about the item */
776 o_ptr->ident |= (IDENT_KNOWN);
780 * @brief オブジェクトを*鑑定*済にする /
781 * The player is now aware of the effects of the given object.
782 * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
785 void object_aware(object_type *o_ptr)
787 bool mihanmei = !object_is_aware(o_ptr);
789 /* Fully aware of the effects */
790 k_info[o_ptr->k_idx].aware = TRUE;
792 if(mihanmei && !(k_info[o_ptr->k_idx].gen_flags & TRG_INSTA_ART) && record_ident &&
793 !p_ptr->is_dead && ((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || (o_ptr->tval == TV_FOOD)))
797 char o_name[MAX_NLEN];
800 object_copy(q_ptr, o_ptr);
803 object_desc(o_name, q_ptr, OD_NAME_ONLY);
805 do_cmd_write_nikki(NIKKI_HANMEI, 0, o_name);
811 * @brief オブジェクトを試行済にする /
812 * Something has been "sampled"
813 * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
816 void object_tried(object_type *o_ptr)
818 /* Mark it as tried (even if "aware") */
819 k_info[o_ptr->k_idx].tried = TRUE;
824 * @brief 未鑑定なベースアイテムの基本価格を返す /
825 * Return the "value" of an "unknown" item Make a guess at the value of non-aware items
826 * @param o_ptr 未鑑定価格を確認したいオブジェクトの構造体参照ポインタ
827 * @return オブジェクトの未鑑定価格
829 static s32b object_value_base(object_type *o_ptr)
831 /* Aware item -- use template cost */
832 if (object_is_aware(o_ptr)) return (k_info[o_ptr->k_idx].cost);
834 /* Analyze the type */
839 case TV_FOOD: return (5L);
841 /* Un-aware Potions */
842 case TV_POTION: return (20L);
844 /* Un-aware Scrolls */
845 case TV_SCROLL: return (20L);
847 /* Un-aware Staffs */
848 case TV_STAFF: return (70L);
851 case TV_WAND: return (50L);
854 case TV_ROD: return (90L);
857 case TV_RING: return (45L);
859 /* Un-aware Amulets */
860 case TV_AMULET: return (45L);
862 /* Figurines, relative to monster level */
865 int level = r_info[o_ptr->pval].level;
866 if (level < 20) return level*50L;
867 else if (level < 30) return 1000+(level-20)*150L;
868 else if (level < 40) return 2500+(level-30)*350L;
869 else if (level < 50) return 6000+(level-40)*800L;
870 else return 14000+(level-50)*2000L;
874 if (!o_ptr->pval) return 1000L;
875 else return ((r_info[o_ptr->pval].level) * 50L + 1000);
878 /* Paranoia -- Oops */
884 * @brief オブジェクトのフラグ類から価格を算出する /
885 * Return the value of the flags the object has...
886 * @param o_ptr フラグ価格を確認したいオブジェクトの構造体参照ポインタ
887 * @param plusses フラグに与える価格の基本重み
888 * @return オブジェクトのフラグ価格
890 s32b flag_cost(object_type *o_ptr, int plusses)
893 u32b flgs[TR_FLAG_SIZE];
897 object_kind *k_ptr = &k_info[o_ptr->k_idx];
899 object_flags(o_ptr, flgs);
902 * Exclude fixed flags of the base item.
903 * pval bonuses of base item will be treated later.
905 for (i = 0; i < TR_FLAG_SIZE; i++)
906 flgs[i] &= ~(k_ptr->flags[i]);
908 /* Exclude fixed flags of the fixed artifact. */
909 if (object_is_fixed_artifact(o_ptr))
911 artifact_type *a_ptr = &a_info[o_ptr->name1];
913 for (i = 0; i < TR_FLAG_SIZE; i++)
914 flgs[i] &= ~(a_ptr->flags[i]);
917 /* Exclude fixed flags of the ego-item. */
918 else if (object_is_ego(o_ptr))
920 ego_item_type *e_ptr = &e_info[o_ptr->name2];
922 for (i = 0; i < TR_FLAG_SIZE; i++)
923 flgs[i] &= ~(e_ptr->flags[i]);
928 * Calucurate values of remaining flags
930 if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
931 if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
932 if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
933 if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
934 if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
935 if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
936 if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
937 if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
938 if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
939 if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
940 if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
941 if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
942 total += (10000 + (2500 * plusses));
943 if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
944 total += (10000 + (2500 * plusses));
948 if (have_flag(flgs, TR_CHAOTIC)) {total += 5000;count++;}
949 if (have_flag(flgs, TR_VAMPIRIC)) {total += 6500;count++;}
950 if (have_flag(flgs, TR_FORCE_WEAPON)) {tmp_cost += 2500;count++;}
951 if (have_flag(flgs, TR_KILL_ANIMAL)) {tmp_cost += 2800;count++;}
952 else if (have_flag(flgs, TR_SLAY_ANIMAL)) {tmp_cost += 1800;count++;}
953 if (have_flag(flgs, TR_KILL_EVIL)) {tmp_cost += 3300;count++;}
954 else if (have_flag(flgs, TR_SLAY_EVIL)) {tmp_cost += 2300;count++;}
955 if (have_flag(flgs, TR_KILL_HUMAN)) {tmp_cost += 2800;count++;}
956 else if (have_flag(flgs, TR_SLAY_HUMAN)) {tmp_cost += 1800;count++;}
957 if (have_flag(flgs, TR_KILL_UNDEAD)) {tmp_cost += 2800;count++;}
958 else if (have_flag(flgs, TR_SLAY_UNDEAD)) {tmp_cost += 1800;count++;}
959 if (have_flag(flgs, TR_KILL_DEMON)) {tmp_cost += 2800;count++;}
960 else if (have_flag(flgs, TR_SLAY_DEMON)) {tmp_cost += 1800;count++;}
961 if (have_flag(flgs, TR_KILL_ORC)) {tmp_cost += 2500;count++;}
962 else if (have_flag(flgs, TR_SLAY_ORC)) {tmp_cost += 1500;count++;}
963 if (have_flag(flgs, TR_KILL_TROLL)) {tmp_cost += 2800;count++;}
964 else if (have_flag(flgs, TR_SLAY_TROLL)) {tmp_cost += 1800;count++;}
965 if (have_flag(flgs, TR_KILL_GIANT)) {tmp_cost += 2800;count++;}
966 else if (have_flag(flgs, TR_SLAY_GIANT)) {tmp_cost += 1800;count++;}
967 if (have_flag(flgs, TR_KILL_DRAGON)) {tmp_cost += 2800;count++;}
968 else if (have_flag(flgs, TR_SLAY_DRAGON)) {tmp_cost += 1800;count++;}
970 if (have_flag(flgs, TR_VORPAL)) {tmp_cost += 2500;count++;}
971 if (have_flag(flgs, TR_IMPACT)) {tmp_cost += 2500;count++;}
972 if (have_flag(flgs, TR_BRAND_POIS)) {tmp_cost += 3800;count++;}
973 if (have_flag(flgs, TR_BRAND_ACID)) {tmp_cost += 3800;count++;}
974 if (have_flag(flgs, TR_BRAND_ELEC)) {tmp_cost += 3800;count++;}
975 if (have_flag(flgs, TR_BRAND_FIRE)) {tmp_cost += 2500;count++;}
976 if (have_flag(flgs, TR_BRAND_COLD)) {tmp_cost += 2500;count++;}
977 total += (tmp_cost * count);
979 if (have_flag(flgs, TR_SUST_STR)) total += 850;
980 if (have_flag(flgs, TR_SUST_INT)) total += 850;
981 if (have_flag(flgs, TR_SUST_WIS)) total += 850;
982 if (have_flag(flgs, TR_SUST_DEX)) total += 850;
983 if (have_flag(flgs, TR_SUST_CON)) total += 850;
984 if (have_flag(flgs, TR_SUST_CHR)) total += 250;
985 if (have_flag(flgs, TR_RIDING)) total += 0;
986 if (have_flag(flgs, TR_EASY_SPELL)) total += 1500;
987 if (have_flag(flgs, TR_THROW)) total += 5000;
988 if (have_flag(flgs, TR_FREE_ACT)) total += 4500;
989 if (have_flag(flgs, TR_HOLD_EXP)) total += 8500;
993 if (have_flag(flgs, TR_IM_ACID)) {tmp_cost += 15000;count += 2;}
994 if (have_flag(flgs, TR_IM_ELEC)) {tmp_cost += 15000;count += 2;}
995 if (have_flag(flgs, TR_IM_FIRE)) {tmp_cost += 15000;count += 2;}
996 if (have_flag(flgs, TR_IM_COLD)) {tmp_cost += 15000;count += 2;}
997 if (have_flag(flgs, TR_REFLECT)) {tmp_cost += 5000;count += 2;}
998 if (have_flag(flgs, TR_RES_ACID)) {tmp_cost += 500;count++;}
999 if (have_flag(flgs, TR_RES_ELEC)) {tmp_cost += 500;count++;}
1000 if (have_flag(flgs, TR_RES_FIRE)) {tmp_cost += 500;count++;}
1001 if (have_flag(flgs, TR_RES_COLD)) {tmp_cost += 500;count++;}
1002 if (have_flag(flgs, TR_RES_POIS)) {tmp_cost += 1000;count += 2;}
1003 if (have_flag(flgs, TR_RES_FEAR)) {tmp_cost += 1000;count += 2;}
1004 if (have_flag(flgs, TR_RES_LITE)) {tmp_cost += 800;count += 2;}
1005 if (have_flag(flgs, TR_RES_DARK)) {tmp_cost += 800;count += 2;}
1006 if (have_flag(flgs, TR_RES_BLIND)) {tmp_cost += 900;count += 2;}
1007 if (have_flag(flgs, TR_RES_CONF)) {tmp_cost += 900;count += 2;}
1008 if (have_flag(flgs, TR_RES_SOUND)) {tmp_cost += 900;count += 2;}
1009 if (have_flag(flgs, TR_RES_SHARDS)) {tmp_cost += 900;count += 2;}
1010 if (have_flag(flgs, TR_RES_NETHER)) {tmp_cost += 900;count += 2;}
1011 if (have_flag(flgs, TR_RES_NEXUS)) {tmp_cost += 900;count += 2;}
1012 if (have_flag(flgs, TR_RES_CHAOS)) {tmp_cost += 1000;count += 2;}
1013 if (have_flag(flgs, TR_RES_DISEN)) {tmp_cost += 2000;count += 2;}
1014 total += (tmp_cost * count);
1016 if (have_flag(flgs, TR_SH_FIRE)) total += 5000;
1017 if (have_flag(flgs, TR_SH_ELEC)) total += 5000;
1018 if (have_flag(flgs, TR_SH_COLD)) total += 5000;
1019 if (have_flag(flgs, TR_NO_TELE)) total -= 10000;
1020 if (have_flag(flgs, TR_NO_MAGIC)) total += 2500;
1021 if (have_flag(flgs, TR_TY_CURSE)) total -= 15000;
1022 if (have_flag(flgs, TR_HIDE_TYPE)) total += 0;
1023 if (have_flag(flgs, TR_SHOW_MODS)) total += 0;
1024 if (have_flag(flgs, TR_LEVITATION)) total += 1250;
1025 if (have_flag(flgs, TR_LITE_1)) total += 1500;
1026 if (have_flag(flgs, TR_LITE_2)) total += 2500;
1027 if (have_flag(flgs, TR_LITE_3)) total += 4000;
1028 if (have_flag(flgs, TR_LITE_M1)) total -= 1500;
1029 if (have_flag(flgs, TR_LITE_M2)) total -= 2500;
1030 if (have_flag(flgs, TR_LITE_M3)) total -= 4000;
1031 if (have_flag(flgs, TR_SEE_INVIS)) total += 2000;
1032 if (have_flag(flgs, TR_TELEPATHY)) total += 20000;
1033 if (have_flag(flgs, TR_ESP_ANIMAL)) total += 1000;
1034 if (have_flag(flgs, TR_ESP_UNDEAD)) total += 1000;
1035 if (have_flag(flgs, TR_ESP_DEMON)) total += 1000;
1036 if (have_flag(flgs, TR_ESP_ORC)) total += 1000;
1037 if (have_flag(flgs, TR_ESP_TROLL)) total += 1000;
1038 if (have_flag(flgs, TR_ESP_GIANT)) total += 1000;
1039 if (have_flag(flgs, TR_ESP_DRAGON)) total += 1000;
1040 if (have_flag(flgs, TR_ESP_HUMAN)) total += 1000;
1041 if (have_flag(flgs, TR_ESP_EVIL)) total += 15000;
1042 if (have_flag(flgs, TR_ESP_GOOD)) total += 2000;
1043 if (have_flag(flgs, TR_ESP_NONLIVING)) total += 2000;
1044 if (have_flag(flgs, TR_ESP_UNIQUE)) total += 10000;
1045 if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
1046 if (have_flag(flgs, TR_REGEN)) total += 2500;
1047 if (have_flag(flgs, TR_WARNING)) total += 2000;
1048 if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
1049 if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
1050 if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
1051 if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
1052 if (have_flag(flgs, TR_IGNORE_ELEC)) total += 100;
1053 if (have_flag(flgs, TR_IGNORE_FIRE)) total += 100;
1054 if (have_flag(flgs, TR_IGNORE_COLD)) total += 100;
1055 if (have_flag(flgs, TR_ACTIVATE)) total += 100;
1056 if (have_flag(flgs, TR_DRAIN_EXP)) total -= 12500;
1057 if (have_flag(flgs, TR_DRAIN_HP)) total -= 12500;
1058 if (have_flag(flgs, TR_DRAIN_MANA)) total -= 12500;
1059 if (have_flag(flgs, TR_CALL_ANIMAL)) total -= 12500;
1060 if (have_flag(flgs, TR_CALL_DEMON)) total -= 10000;
1061 if (have_flag(flgs, TR_CALL_DRAGON)) total -= 10000;
1062 if (have_flag(flgs, TR_CALL_UNDEAD)) total -= 10000;
1063 if (have_flag(flgs, TR_COWARDICE)) total -= 5000;
1064 if (have_flag(flgs, TR_LOW_MELEE)) total -= 5000;
1065 if (have_flag(flgs, TR_LOW_AC)) total -= 5000;
1066 if (have_flag(flgs, TR_LOW_MAGIC)) total -= 15000;
1067 if (have_flag(flgs, TR_FAST_DIGEST)) total -= 10000;
1068 if (have_flag(flgs, TR_SLOW_REGEN)) total -= 10000;
1069 if (have_flag(flgs, TR_TELEPORT))
1071 if (object_is_cursed(o_ptr))
1076 if (have_flag(flgs, TR_AGGRAVATE)) total -= 10000;
1077 if (have_flag(flgs, TR_BLESSED)) total += 750;
1078 if (o_ptr->curse_flags & TR_ADD_L_CURSE) total -= 5000;
1079 if (o_ptr->curse_flags & TR_ADD_H_CURSE) total -= 12500;
1080 if (o_ptr->curse_flags & TRC_CURSED) total -= 5000;
1081 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) total -= 12500;
1082 if (o_ptr->curse_flags & TRC_PERMA_CURSE) total -= 15000;
1084 /* Also, give some extra for activatable powers... */
1085 if (o_ptr->art_name && (have_flag(o_ptr->art_flags, TR_ACTIVATE)))
1087 const activation_type* const act_ptr = find_activation_info(o_ptr);
1089 total += act_ptr->value;
1098 * @brief オブジェクトの真の価格を算出する /
1099 * Return the value of the flags the object has...
1100 * @param o_ptr 本価格を確認したいオブジェクトの構造体参照ポインタ
1101 * @return オブジェクトの本価格
1103 * Return the "real" price of a "known" item, not including discounts\n
1105 * Wand and staffs get cost for each charge\n
1107 * Armor is worth an extra 100 gold per bonus point to armor class.\n
1109 * Weapons are worth an extra 100 gold per bonus point (AC,TH,TD).\n
1111 * Missiles are only worth 5 gold per bonus point, since they\n
1112 * usually appear in groups of 20, and we want the player to get\n
1113 * the same amount of cash for any "equivalent" item. Note that\n
1114 * missiles never have any of the "pval" flags, and in fact, they\n
1115 * only have a few of the available flags, primarily of the "slay"\n
1116 * and "brand" and "ignore" variety.\n
1118 * Armor with a negative armor bonus is worthless.\n
1119 * Weapons with negative hit+damage bonuses are worthless.\n
1121 * Every wearable item with a "pval" bonus is worth extra (see below).\n
1123 s32b object_value_real(object_type *o_ptr)
1127 u32b flgs[TR_FLAG_SIZE];
1129 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1132 /* Hack -- "worthless" items */
1133 if (!k_info[o_ptr->k_idx].cost) return (0L);
1136 value = k_info[o_ptr->k_idx].cost;
1138 /* Extract some flags */
1139 object_flags(o_ptr, flgs);
1142 if (object_is_fixed_artifact(o_ptr))
1144 artifact_type *a_ptr = &a_info[o_ptr->name1];
1146 /* Hack -- "worthless" artifacts */
1147 if (!a_ptr->cost) return (0L);
1149 /* Hack -- Use the artifact cost instead */
1150 value = a_ptr->cost;
1151 value += flag_cost(o_ptr, o_ptr->pval);
1153 /* Don't add pval bonuses etc. */
1158 else if (object_is_ego(o_ptr))
1160 ego_item_type *e_ptr = &e_info[o_ptr->name2];
1162 /* Hack -- "worthless" ego-items */
1163 if (!e_ptr->cost) return (0L);
1165 /* Hack -- Reward the ego-item with a bonus */
1166 value += e_ptr->cost;
1167 value += flag_cost(o_ptr, o_ptr->pval);
1175 for (i = 0; i < TR_FLAG_SIZE; i++)
1176 if (o_ptr->art_flags[i]) flag = TRUE;
1178 if (flag) value += flag_cost(o_ptr, o_ptr->pval);
1181 /* Analyze pval bonus for normal object */
1182 switch (o_ptr->tval)
1205 if (!o_ptr->pval) break;
1207 /* Hack -- Negative "pval" is always bad */
1208 if (o_ptr->pval < 0) return (0L);
1210 /* Give credit for stat bonuses */
1211 if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
1212 if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
1213 if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
1214 if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
1215 if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
1216 if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
1218 /* Give credit for stealth and searching */
1219 if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
1220 if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
1221 if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
1223 /* Give credit for infra-vision and tunneling */
1224 if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
1225 if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
1227 /* Give credit for extra attacks */
1228 if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
1230 /* Give credit for speed bonus */
1231 if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
1237 /* Analyze the item */
1238 switch (o_ptr->tval)
1243 /* Pay extra for charges, depending on standard number of
1244 * charges. Handle new-style wands correctly. -LM-
1246 value += (value * o_ptr->pval / o_ptr->number / (k_ptr->pval * 2));
1253 /* Pay extra for charges, depending on standard number of
1256 value += (value * o_ptr->pval / (k_ptr->pval * 2));
1266 /* Hack -- negative bonuses are bad */
1267 if (o_ptr->to_h + o_ptr->to_d + o_ptr->to_a < 0) return (0L);
1269 /* Give credit for bonuses */
1270 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 200L);
1287 /* Hack -- negative armor bonus */
1288 if (o_ptr->to_a < 0) return (0L);
1290 /* Give credit for bonuses */
1291 value += (((o_ptr->to_h - k_ptr->to_h) + (o_ptr->to_d - k_ptr->to_d)) * 200L + (o_ptr->to_a) * 100L);
1304 /* Hack -- negative hit/damage bonuses */
1305 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1307 /* Factor in the bonuses */
1308 value += ((o_ptr->to_h + o_ptr->to_d + o_ptr->to_a) * 100L);
1310 /* Hack -- Factor in extra damage dice and sides */
1311 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 250L;
1312 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 250L;
1323 /* Hack -- negative hit/damage bonuses */
1324 if (o_ptr->to_h + o_ptr->to_d < 0) return (0L);
1326 /* Factor in the bonuses */
1327 value += ((o_ptr->to_h + o_ptr->to_d) * 5L);
1329 /* Hack -- Factor in extra damage dice and sides */
1330 value += (o_ptr->dd - k_ptr->dd) * o_ptr->ds * 5L;
1331 value += (o_ptr->ds - k_ptr->ds) * o_ptr->dd * 5L;
1337 /* Figurines, relative to monster level */
1340 int level = r_info[o_ptr->pval].level;
1341 if (level < 20) value = level*50L;
1342 else if (level < 30) value = 1000+(level-20)*150L;
1343 else if (level < 40) value = 2500+(level-30)*350L;
1344 else if (level < 50) value = 6000+(level-40)*800L;
1345 else value = 14000+(level-50)*2000L;
1351 if (!o_ptr->pval) value = 1000L;
1352 else value = ((r_info[o_ptr->pval].level) * 50L + 1000);
1358 if (!o_ptr->pval) value = 0L;
1363 /* Worthless object */
1364 if (value < 0) return 0L;
1366 /* Return the value */
1372 * @brief オブジェクト価格算出のメインルーチン /
1373 * Return the price of an item including plusses (and charges)
1374 * @param o_ptr 判明している現価格を確認したいオブジェクトの構造体参照ポインタ
1375 * @return オブジェクトの判明している現価格
1377 * This function returns the "value" of the given item (qty one)\n
1379 * Never notice "unknown" bonuses or properties, including "curses",\n
1380 * since that would give the player information he did not have.\n
1382 * Note that discounted items stay discounted forever, even if\n
1383 * the discount is "forgotten" by the player via memory loss.\n
1385 s32b object_value(object_type *o_ptr)
1390 /* Unknown items -- acquire a base value */
1391 if (object_is_known(o_ptr))
1393 /* Broken items -- worthless */
1394 if (object_is_broken(o_ptr)) return (0L);
1396 /* Cursed items -- worthless */
1397 if (object_is_cursed(o_ptr)) return (0L);
1399 /* Real value (see above) */
1400 value = object_value_real(o_ptr);
1403 /* Known items -- acquire the actual value */
1406 /* Hack -- Felt broken items */
1407 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_broken(o_ptr)) return (0L);
1409 /* Hack -- Felt cursed items */
1410 if ((o_ptr->ident & (IDENT_SENSE)) && object_is_cursed(o_ptr)) return (0L);
1412 /* Base value (see above) */
1413 value = object_value_base(o_ptr);
1417 /* Apply discount (if any) */
1418 if (o_ptr->discount) value -= (value * o_ptr->discount / 100L);
1421 /* Return the final value */
1428 * @brief 破壊可能なアイテムかを返す /
1429 * Determines whether an object can be destroyed, and makes fake inscription.
1430 * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
1431 * @return オブジェクトが破壊可能ならばTRUEを返す
1433 bool can_player_destroy_object(object_type *o_ptr)
1435 /* Artifacts cannot be destroyed */
1436 if (!object_is_artifact(o_ptr)) return TRUE;
1438 /* If object is unidentified, makes fake inscription */
1439 if (!object_is_known(o_ptr))
1441 byte feel = FEEL_SPECIAL;
1443 /* Hack -- Handle icky artifacts */
1444 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) feel = FEEL_TERRIBLE;
1446 /* Hack -- inscribe the artifact */
1447 o_ptr->feeling = feel;
1449 /* We have "felt" it (again) */
1450 o_ptr->ident |= (IDENT_SENSE);
1452 /* Combine the pack */
1453 p_ptr->notice |= (PN_COMBINE);
1456 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1462 /* Identified artifact -- Nothing to do */
1468 * @brief 魔法棒やロッドのスロット分割時に使用回数を分配する /
1469 * Distribute charges of rods or wands.
1470 * @param o_ptr 分割元オブジェクトの構造体参照ポインタ source item
1471 * @param q_ptr 分割先オブジェクトの構造体参照ポインタ target item, must be of the same type as o_ptr
1472 * @param amt 分割したい回数量 number of items that are transfered
1475 * Hack -- If rods or wands are dropped, the total maximum timeout or\n
1476 * charges need to be allocated between the two stacks. If all the items\n
1477 * are being dropped, it makes for a neater message to leave the original\n
1478 * stack's pval alone. -LM-\n
1480 void distribute_charges(object_type *o_ptr, object_type *q_ptr, int amt)
1482 if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD))
1484 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
1485 if (amt < o_ptr->number) o_ptr->pval -= q_ptr->pval;
1487 /* Hack -- Rods also need to have their timeouts distributed. The
1488 * dropped stack will accept all time remaining to charge up to its
1491 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
1493 if (q_ptr->pval > o_ptr->timeout)
1494 q_ptr->timeout = o_ptr->timeout;
1496 q_ptr->timeout = q_ptr->pval;
1498 if (amt < o_ptr->number) o_ptr->timeout -= q_ptr->timeout;
1504 * @brief 魔法棒やロッドの使用回数を減らす /
1505 * @param o_ptr オブジェクトの構造体参照ポインタ source item
1506 * @param amt 減らしたい回数量 number of items that are transfered
1509 * Hack -- If rods or wand are destroyed, the total maximum timeout or\n
1510 * charges of the stack needs to be reduced, unless all the items are\n
1511 * being destroyed. -LM-\n
1513 void reduce_charges(object_type *o_ptr, int amt)
1515 if (((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_ROD)) &&
1516 (amt < o_ptr->number))
1518 o_ptr->pval -= o_ptr->pval * amt / o_ptr->number;
1523 * Determine if an item can "absorb" a second item
1525 * See "object_absorb()" for the actual "absorption" code.
1527 * If permitted, we allow staffs (if they are known to have equal charges
1528 * and both are either known or confirmed empty) and wands (if both are
1529 * either known or confirmed empty) and rods (in all cases) to combine.
1530 * Staffs will unstack (if necessary) when they are used, but wands and
1531 * rods will only unstack if one is dropped. -LM-
1533 * If permitted, we allow weapons/armor to stack, if fully "known".
1535 * Missiles will combine if both stacks have the same "known" status.
1536 * This is done to make unidentified stacks of missiles useful.
1538 * Food, potions, scrolls, and "easy know" items always stack.
1540 * Chests, and activatable items, never stack (for various reasons).
1544 * A "stack" of items is limited to less than or equal to 99 items (hard-coded).
1546 #define MAX_STACK_SIZE 99
1550 * @brief 両オブジェクトをスロットに重ね合わせ可能な最大数を返す。
1551 * Determine if an item can partly absorb a second item. Return maximum number of stack.
1552 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1553 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1554 * @return 重ね合わせ可能なアイテム数
1556 int object_similar_part(object_type *o_ptr, object_type *j_ptr)
1560 /* Default maximum number of stack */
1561 int max_num = MAX_STACK_SIZE;
1563 /* Require identical object types */
1564 if (o_ptr->k_idx != j_ptr->k_idx) return 0;
1567 /* Analyze the items */
1568 switch (o_ptr->tval)
1570 /* Chests and Statues*/
1581 if ((o_ptr->sval != SV_PHOTO) || (j_ptr->sval != SV_PHOTO)) return 0;
1582 if (o_ptr->pval != j_ptr->pval) return 0;
1586 /* Figurines and Corpses*/
1591 if (o_ptr->pval != j_ptr->pval) return 0;
1597 /* Food and Potions and Scrolls */
1609 /* Require either knowledge or known empty for both staffs. */
1610 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1611 !object_is_known(o_ptr)) ||
1612 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1613 !object_is_known(j_ptr))) return 0;
1615 /* Require identical charges, since staffs are bulky. */
1616 if (o_ptr->pval != j_ptr->pval) return 0;
1625 /* Require either knowledge or known empty for both wands. */
1626 if ((!(o_ptr->ident & (IDENT_EMPTY)) &&
1627 !object_is_known(o_ptr)) ||
1628 (!(j_ptr->ident & (IDENT_EMPTY)) &&
1629 !object_is_known(j_ptr))) return 0;
1631 /* Wand charges combine in O&ZAngband. */
1637 /* Staffs and Wands and Rods */
1640 /* Prevent overflaw of timeout */
1641 max_num = MIN(max_num, MAX_SHORT / k_info[o_ptr->k_idx].pval);
1647 /* Weapons and Armor */
1663 /* Rings, Amulets, Lites */
1669 /* Require full knowledge of both items */
1670 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1680 /* Require identical knowledge of both items */
1681 if (object_is_known(o_ptr) != object_is_known(j_ptr)) return 0;
1682 if (o_ptr->feeling != j_ptr->feeling) return 0;
1684 /* Require identical "bonuses" */
1685 if (o_ptr->to_h != j_ptr->to_h) return 0;
1686 if (o_ptr->to_d != j_ptr->to_d) return 0;
1687 if (o_ptr->to_a != j_ptr->to_a) return 0;
1689 /* Require identical "pval" code */
1690 if (o_ptr->pval != j_ptr->pval) return 0;
1692 /* Artifacts never stack */
1693 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return 0;
1695 /* Require identical "ego-item" names */
1696 if (o_ptr->name2 != j_ptr->name2) return 0;
1698 /* Require identical added essence */
1699 if (o_ptr->xtra3 != j_ptr->xtra3) return 0;
1700 if (o_ptr->xtra4 != j_ptr->xtra4) return 0;
1702 /* Hack -- Never stack "powerful" items */
1703 if (o_ptr->xtra1 || j_ptr->xtra1) return 0;
1705 /* Hack -- Never stack recharging items */
1706 if (o_ptr->timeout || j_ptr->timeout) return 0;
1708 /* Require identical "values" */
1709 if (o_ptr->ac != j_ptr->ac) return 0;
1710 if (o_ptr->dd != j_ptr->dd) return 0;
1711 if (o_ptr->ds != j_ptr->ds) return 0;
1720 /* Require knowledge */
1721 if (!object_is_known(o_ptr) || !object_is_known(j_ptr)) return 0;
1729 /* Hack -- Identical art_flags! */
1730 for (i = 0; i < TR_FLAG_SIZE; i++)
1731 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return 0;
1733 /* Hack -- Require identical "cursed" status */
1734 if (o_ptr->curse_flags != j_ptr->curse_flags) return 0;
1736 /* Hack -- Require identical "broken" status */
1737 if ((o_ptr->ident & (IDENT_BROKEN)) != (j_ptr->ident & (IDENT_BROKEN))) return 0;
1740 /* Hack -- require semi-matching "inscriptions" */
1741 if (o_ptr->inscription && j_ptr->inscription &&
1742 (o_ptr->inscription != j_ptr->inscription))
1745 /* Hack -- normally require matching "inscriptions" */
1746 if (!stack_force_notes && (o_ptr->inscription != j_ptr->inscription)) return 0;
1748 /* Hack -- normally require matching "discounts" */
1749 if (!stack_force_costs && (o_ptr->discount != j_ptr->discount)) return 0;
1752 /* They match, so they must be similar */
1757 * @brief 両オブジェクトをスロットに重ねることができるかどうかを返す。
1758 * Determine if an item can absorb a second item.
1759 * @param o_ptr 検証したいオブジェクトの構造体参照ポインタ1
1760 * @param j_ptr 検証したいオブジェクトの構造体参照ポインタ2
1761 * @return 重ね合わせ可能ならばTRUEを返す。
1763 bool object_similar(object_type *o_ptr, object_type *j_ptr)
1765 int total = o_ptr->number + j_ptr->number;
1768 /* Are these objects similar? */
1769 max_num = object_similar_part(o_ptr, j_ptr);
1771 /* Return if not similar */
1772 if (!max_num) return FALSE;
1774 /* Maximal "stacking" limit */
1775 if (total > max_num) return (0);
1778 /* They match, so they must be similar */
1784 * @brief 両オブジェクトをスロットに重ね合わせる。
1785 * Allow one item to "absorb" another, assuming they are similar
1786 * @param o_ptr 重ね合わせ先のオブジェクトの構造体参照ポインタ
1787 * @param j_ptr 重ね合わせ元のオブジェクトの構造体参照ポインタ
1790 void object_absorb(object_type *o_ptr, object_type *j_ptr)
1792 int max_num = object_similar_part(o_ptr, j_ptr);
1793 int total = o_ptr->number + j_ptr->number;
1794 int diff = (total > max_num) ? total - max_num : 0;
1796 /* Combine quantity, lose excess items */
1797 o_ptr->number = (total > max_num) ? max_num : total;
1799 /* Hack -- blend "known" status */
1800 if (object_is_known(j_ptr)) object_known(o_ptr);
1802 /* Hack -- clear "storebought" if only one has it */
1803 if (((o_ptr->ident & IDENT_STORE) || (j_ptr->ident & IDENT_STORE)) &&
1804 (!((o_ptr->ident & IDENT_STORE) && (j_ptr->ident & IDENT_STORE))))
1806 if (j_ptr->ident & IDENT_STORE) j_ptr->ident &= 0xEF;
1807 if (o_ptr->ident & IDENT_STORE) o_ptr->ident &= 0xEF;
1810 /* Hack -- blend "mental" status */
1811 if (j_ptr->ident & (IDENT_MENTAL)) o_ptr->ident |= (IDENT_MENTAL);
1813 /* Hack -- blend "inscriptions" */
1814 if (j_ptr->inscription) o_ptr->inscription = j_ptr->inscription;
1816 /* Hack -- blend "feelings" */
1817 if (j_ptr->feeling) o_ptr->feeling = j_ptr->feeling;
1819 /* Hack -- could average discounts XXX XXX XXX */
1820 /* Hack -- save largest discount XXX XXX XXX */
1821 if (o_ptr->discount < j_ptr->discount) o_ptr->discount = j_ptr->discount;
1823 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1824 if (o_ptr->tval == TV_ROD)
1826 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1827 o_ptr->timeout += j_ptr->timeout * (j_ptr->number - diff) / j_ptr->number;
1830 /* Hack -- if wands are stacking, combine the charges. -LM- */
1831 if (o_ptr->tval == TV_WAND)
1833 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1839 * @brief tvalとsvalに対応するベースアイテムのIDを返す。
1840 * Find the index of the object_kind with the given tval and sval
1841 * @param tval 検索したいベースアイテムのtval
1842 * @param sval 検索したいベースアイテムのsval
1845 s16b lookup_kind(int tval, int sval)
1852 for (k = 1; k < max_k_idx; k++)
1854 object_kind *k_ptr = &k_info[k];
1856 /* Require correct tval */
1857 if (k_ptr->tval != tval) continue;
1860 if (k_ptr->sval == sval) return (k);
1862 /* Ignore illegal items */
1863 if (sval != SV_ANY) continue;
1865 /* Apply the randomizer */
1866 if (!one_in_(++num)) continue;
1868 /* Use this value */
1872 /* Return this choice */
1880 msg_format(_("アイテムがない (%d,%d)", "No object (%d,%d)"), tval, sval);
1890 * @brief オブジェクトを初期化する
1891 * Wipe an object clean.
1892 * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ
1895 void object_wipe(object_type *o_ptr)
1897 /* Wipe the structure */
1898 (void)WIPE(o_ptr, object_type);
1903 * @brief オブジェクトを複製する
1904 * Wipe an object clean.
1905 * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ
1906 * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ
1909 void object_copy(object_type *o_ptr, object_type *j_ptr)
1911 /* Copy the structure */
1912 (void)COPY(o_ptr, j_ptr, object_type);
1917 * @brief オブジェクト構造体にベースアイテムを作成する
1918 * Prepare an object based on an object kind.
1919 * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ
1920 * @param k_idx 新たに作成したいベースアイテム情報のID
1923 void object_prep(object_type *o_ptr, int k_idx)
1925 object_kind *k_ptr = &k_info[k_idx];
1927 /* Clear the record */
1930 /* Save the kind index */
1931 o_ptr->k_idx = k_idx;
1933 /* Efficiency -- tval/sval */
1934 o_ptr->tval = k_ptr->tval;
1935 o_ptr->sval = k_ptr->sval;
1937 /* Default "pval" */
1938 o_ptr->pval = k_ptr->pval;
1940 /* Default number */
1943 /* Default weight */
1944 o_ptr->weight = k_ptr->weight;
1947 o_ptr->to_h = k_ptr->to_h;
1948 o_ptr->to_d = k_ptr->to_d;
1949 o_ptr->to_a = k_ptr->to_a;
1952 o_ptr->ac = k_ptr->ac;
1953 o_ptr->dd = k_ptr->dd;
1954 o_ptr->ds = k_ptr->ds;
1956 /* Default activation */
1957 if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
1959 /* Hack -- worthless items are always "broken" */
1960 if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
1962 /* Hack -- cursed items are always "cursed" */
1963 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
1964 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
1965 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
1966 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
1967 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
1968 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
1973 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
1974 * Help determine an "enchantment bonus" for an object.
1975 * @param max ボーナス値の限度
1976 * @param level ボーナス値に加味する基準生成階
1977 * @return 算出されたボーナス値
1979 * To avoid floating point but still provide a smooth distribution of bonuses,\n
1980 * we simply round the results of division in such a way as to "average" the\n
1981 * correct floating point value.\n
1983 * This function has been changed. It uses "randnor()" to choose values from\n
1984 * a normal distribution, whose mean moves from zero towards the max as the\n
1985 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
1986 * and whose values are forced to lie between zero and the max, inclusive.\n
1988 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
1989 * rare to get the "full" enchantment on an object, even a deep levels.\n
1991 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
1993 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
1995 * N 0 1 2 3 4 5 6 7 8 9 10\n
1996 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
1997 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
1998 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
1999 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
2000 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
2001 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
2002 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
2003 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
2004 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
2005 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
2006 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
2007 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
2008 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
2009 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
2010 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
2011 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
2012 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
2013 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
2015 s16b m_bonus(int max, int level)
2017 int bonus, stand, extra, value;
2020 /* Paranoia -- enforce maximal "level" */
2021 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
2024 /* The "bonus" moves towards the max */
2025 bonus = ((max * level) / MAX_DEPTH);
2027 /* Hack -- determine fraction of error */
2028 extra = ((max * level) % MAX_DEPTH);
2030 /* Hack -- simulate floating point computations */
2031 if (randint0(MAX_DEPTH) < extra) bonus++;
2034 /* The "stand" is equal to one quarter of the max */
2037 /* Hack -- determine fraction of error */
2040 /* Hack -- simulate floating point computations */
2041 if (randint0(4) < extra) stand++;
2044 /* Choose an "interesting" value */
2045 value = randnor(bonus, stand);
2047 /* Enforce the minimum value */
2048 if (value < 0) return (0);
2050 /* Enforce the maximum value */
2051 if (value > max) return (max);
2059 * @brief デバッグ時にアイテム生成情報をメッセージに出力する / Cheat -- describe a created object for the user
2060 * @param o_ptr デバッグ出力するオブジェクトの構造体参照ポインタ
2063 static void object_mention(object_type *o_ptr)
2065 char o_name[MAX_NLEN];
2068 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
2071 if (object_is_fixed_artifact(o_ptr))
2074 msg_format(_("伝説のアイテム (%s)", "Artifact (%s)"), o_name);
2077 /* Random Artifact */
2078 else if (o_ptr->art_name)
2080 msg_print(_("ランダム・アーティファクト", "Random artifact"));
2084 else if (object_is_ego(o_ptr))
2087 msg_format(_("名のあるアイテム (%s)", "Ego-item (%s)"), o_name);
2094 msg_format(_("アイテム (%s)", "Object (%s)"), o_name);
2099 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2100 * Mega-Hack -- Attempt to create one of the "Special Objects"
2101 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2102 * @return 生成に成功したらTRUEを返す。
2104 * We are only called from "make_object()", and we assume that\n
2105 * "apply_magic()" is called immediately after we return.\n
2107 * Note -- see "make_artifact()" and "apply_magic()"\n
2109 static bool make_artifact_special(object_type *o_ptr)
2115 /* No artifacts in the town */
2116 if (!dun_level) return (FALSE);
2119 if (get_obj_num_hook) return (FALSE);
2121 /* Check the artifact list (just the "specials") */
2122 for (i = 0; i < max_a_idx; i++)
2124 artifact_type *a_ptr = &a_info[i];
2126 /* Skip "empty" artifacts */
2127 if (!a_ptr->name) continue;
2129 /* Cannot make an artifact twice */
2130 if (a_ptr->cur_num) continue;
2132 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2133 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2135 /* XXX XXX Enforce minimum "depth" (loosely) */
2136 if (a_ptr->level > dun_level)
2138 /* Acquire the "out-of-depth factor" */
2139 int d = (a_ptr->level - dun_level) * 2;
2141 /* Roll for out-of-depth creation */
2142 if (!one_in_(d)) continue;
2145 /* Artifact "rarity roll" */
2146 if (!one_in_(a_ptr->rarity)) continue;
2148 /* Find the base object */
2149 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2151 /* XXX XXX Enforce minimum "object" level (loosely) */
2152 if (k_info[k_idx].level > object_level)
2154 /* Acquire the "out-of-depth factor" */
2155 int d = (k_info[k_idx].level - object_level) * 5;
2157 /* Roll for out-of-depth creation */
2158 if (!one_in_(d)) continue;
2161 /* Assign the template */
2162 object_prep(o_ptr, k_idx);
2164 /* Mega-Hack -- mark the item as an artifact */
2167 /* Hack: Some artifacts get random extra powers */
2168 random_artifact_resistance(o_ptr, a_ptr);
2180 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2181 * Mega-Hack -- Attempt to create one of the "Special Objects"
2182 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2183 * @return 生成に成功したらTRUEを返す。
2185 * Attempt to change an object into an artifact\n
2186 * This routine should only be called by "apply_magic()"\n
2187 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2189 static bool make_artifact(object_type *o_ptr)
2194 /* No artifacts in the town */
2195 if (!dun_level) return (FALSE);
2197 /* Paranoia -- no "plural" artifacts */
2198 if (o_ptr->number != 1) return (FALSE);
2200 /* Check the artifact list (skip the "specials") */
2201 for (i = 0; i < max_a_idx; i++)
2203 artifact_type *a_ptr = &a_info[i];
2205 /* Skip "empty" items */
2206 if (!a_ptr->name) continue;
2208 /* Cannot make an artifact twice */
2209 if (a_ptr->cur_num) continue;
2211 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2213 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2215 /* Must have the correct fields */
2216 if (a_ptr->tval != o_ptr->tval) continue;
2217 if (a_ptr->sval != o_ptr->sval) continue;
2219 /* XXX XXX Enforce minimum "depth" (loosely) */
2220 if (a_ptr->level > dun_level)
2222 /* Acquire the "out-of-depth factor" */
2223 int d = (a_ptr->level - dun_level) * 2;
2225 /* Roll for out-of-depth creation */
2226 if (!one_in_(d)) continue;
2229 /* We must make the "rarity roll" */
2230 if (!one_in_(a_ptr->rarity)) continue;
2232 /* Hack -- mark the item as an artifact */
2235 /* Hack: Some artifacts get random extra powers */
2236 random_artifact_resistance(o_ptr, a_ptr);
2248 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2249 * Choose random ego type
2250 * @param slot 取得したいエゴの装備部位
2251 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2252 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2254 static byte get_random_ego(byte slot, bool good)
2257 ego_item_type *e_ptr;
2261 for (i = 1; i < max_e_idx; i++)
2265 if (e_ptr->slot == slot
2266 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2269 total += (255 / e_ptr->rarity);
2273 value = randint1(total);
2275 for (i = 1; i < max_e_idx; i++)
2279 if (e_ptr->slot == slot
2280 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2283 value -= (255 / e_ptr->rarity);
2284 if (value <= 0L) break;
2292 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2293 * Apply magic to an item known to be a "weapon"
2294 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2295 * @param level 生成基準階
2296 * @param power 生成ランク
2299 * Hack -- note special base damage dice boosting\n
2300 * Hack -- note special processing for weapon/digger\n
2302 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2304 int tohit1 = randint1(5) + m_bonus(5, level);
2305 int todam1 = randint1(5) + m_bonus(5, level);
2307 int tohit2 = m_bonus(10, level);
2308 int todam2 = m_bonus(10, level);
2310 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2312 tohit2 = (tohit2+1)/2;
2313 todam2 = (todam2+1)/2;
2320 o_ptr->to_h += tohit1;
2321 o_ptr->to_d += todam1;
2327 o_ptr->to_h += tohit2;
2328 o_ptr->to_d += todam2;
2336 o_ptr->to_h -= tohit1;
2337 o_ptr->to_d -= todam1;
2342 /* Penalize again */
2343 o_ptr->to_h -= tohit2;
2344 o_ptr->to_d -= todam2;
2347 /* Cursed (if "bad") */
2348 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2351 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2354 switch (o_ptr->tval)
2361 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2362 create_artifact(o_ptr, FALSE);
2364 /* Special Ego-item */
2365 o_ptr->name2 = EGO_DIGGING;
2369 else if (power < -1)
2371 /* Hack -- Horrible digging bonus */
2372 o_ptr->pval = 0 - (5 + randint1(5));
2378 /* Hack -- Reverse digging bonus */
2379 o_ptr->pval = 0 - (o_ptr->pval);
2393 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2395 create_artifact(o_ptr, FALSE);
2400 /* Roll for an ego-item */
2401 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2402 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2404 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2406 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2411 switch (o_ptr->name2)
2414 if (one_in_(4) && (level > 40))
2415 add_flag(o_ptr->art_flags, TR_BLOWS);
2419 add_flag(o_ptr->art_flags, TR_RES_POIS);
2421 add_flag(o_ptr->art_flags, TR_WARNING);
2423 case EGO_KILL_DRAGON:
2425 add_flag(o_ptr->art_flags, TR_RES_POIS);
2429 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2431 case EGO_SLAYING_WEAPON:
2432 if (one_in_(3)) /* double damage */
2440 while (one_in_(o_ptr->dd));
2446 while (one_in_(o_ptr->ds));
2451 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2453 if (o_ptr->tval == TV_SWORD && one_in_(3))
2455 add_flag(o_ptr->art_flags, TR_VORPAL);
2460 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2466 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2468 add_flag(o_ptr->art_flags, TR_DEX);
2470 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2473 o_ptr->pval = m_bonus(5, level) + 1;
2475 case EGO_EARTHQUAKES:
2476 if (one_in_(3) && (level > 60))
2477 add_flag(o_ptr->art_flags, TR_BLOWS);
2479 o_ptr->pval = m_bonus(3, level);
2483 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2487 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2489 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2491 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2492 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2495 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2496 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2497 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2498 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2502 if (!o_ptr->art_name)
2504 /* Hack -- Super-charge the damage dice */
2505 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2507 /* Hack -- Lower the damage dice */
2508 if (o_ptr->dd > 9) o_ptr->dd = 9;
2513 else if (power < -1)
2515 /* Roll for ego-item */
2516 if (randint0(MAX_DEPTH) < level)
2520 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2521 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2527 switch (o_ptr->name2)
2530 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2531 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2533 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2534 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2535 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2536 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2537 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2538 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2552 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2554 create_artifact(o_ptr, FALSE);
2557 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2571 if (power > 2) /* power > 2 is debug only */
2573 create_artifact(o_ptr, FALSE);
2577 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2579 switch (o_ptr->name2)
2581 case EGO_SLAYING_BOLT:
2586 /* Hack -- super-charge the damage dice */
2587 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2589 /* Hack -- restrict the damage dice */
2590 if (o_ptr->dd > 9) o_ptr->dd = 9;
2594 else if (power < -1)
2596 /* Roll for ego-item */
2597 if (randint0(MAX_DEPTH) < level)
2599 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2609 * @brief ドラゴン装備にランダムな耐性を与える
2610 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2613 static void dragon_resist(object_type * o_ptr)
2618 one_dragon_ele_resistance(o_ptr);
2620 one_high_resistance(o_ptr);
2626 * @brief オブジェクトにランダムな強いESPを与える
2627 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2630 static bool add_esp_strong(object_type *o_ptr)
2632 bool nonliv = FALSE;
2634 switch (randint1(3))
2636 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2637 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2638 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2645 * @brief オブジェクトにランダムな弱いESPを与える
2646 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2647 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2650 static void add_esp_weak(object_type *o_ptr, bool extra)
2653 u32b weak_esp_list[] = {
2665 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2666 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2668 /* Add unduplicated weak esp flags randomly */
2669 for (i = 0; i < add_count; ++ i)
2671 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2673 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2674 weak_esp_list[choice] = weak_esp_list[i];
2680 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2681 * Apply magic to an item known to be "armor"
2682 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2683 * @param level 生成基準階
2684 * @param power 生成ランク
2687 * Hack -- note special processing for crown/helm\n
2688 * Hack -- note special processing for robe of permanence\n
2690 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2692 int toac1 = randint1(5) + m_bonus(5, level);
2694 int toac2 = m_bonus(10, level);
2700 o_ptr->to_a += toac1;
2706 o_ptr->to_a += toac2;
2714 o_ptr->to_a -= toac1;
2719 /* Penalize again */
2720 o_ptr->to_a -= toac2;
2723 /* Cursed (if "bad") */
2724 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2729 switch (o_ptr->tval)
2733 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2734 create_artifact(o_ptr, FALSE);
2736 /* Mention the item */
2737 if (cheat_peek) object_mention(o_ptr);
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)
2801 switch (o_ptr->name2)
2803 case EGO_RESISTANCE:
2805 add_flag(o_ptr->art_flags, TR_RES_POIS);
2808 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2809 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2813 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2815 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2817 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2818 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2820 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2821 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2822 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2823 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2824 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2825 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2826 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2827 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2830 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2831 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2832 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2833 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2834 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2835 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2848 if (o_ptr->sval == SV_DRAGON_SHIELD)
2850 /* Mention the item */
2851 if (cheat_peek) object_mention(o_ptr);
2852 dragon_resist(o_ptr);
2853 if (!one_in_(3)) break;
2859 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2861 create_artifact(o_ptr, FALSE);
2867 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2868 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2869 && o_ptr->name2 == EGO_S_DWARVEN)
2876 switch (o_ptr->name2)
2879 if (!one_in_(3)) one_high_resistance(o_ptr);
2880 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2882 case EGO_REFLECTION:
2883 if (o_ptr->sval == SV_MIRROR_SHIELD)
2888 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2889 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2898 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2900 /* Mention the item */
2901 if (cheat_peek) object_mention(o_ptr);
2902 dragon_resist(o_ptr);
2903 if (!one_in_(3)) break;
2907 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2909 create_artifact(o_ptr, FALSE);
2912 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2916 else if (power < -1)
2918 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2926 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2928 /* Mention the item */
2929 if (cheat_peek) object_mention(o_ptr);
2930 dragon_resist(o_ptr);
2931 if (!one_in_(3)) break;
2936 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2938 create_artifact(o_ptr, FALSE);
2941 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2943 switch (o_ptr->name2)
2945 case EGO_SLOW_DESCENT:
2948 one_high_resistance(o_ptr);
2954 else if (power < -1)
2956 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2967 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2969 create_artifact(o_ptr, FALSE);
2974 bool ok_flag = TRUE;
2975 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2977 switch (o_ptr->name2)
2980 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2981 else add_esp_weak(o_ptr, FALSE);
2985 case EGO_REGENERATION:
2986 case EGO_LORDLINESS:
2992 if (one_in_(2)) add_esp_strong(o_ptr);
2993 else add_esp_weak(o_ptr, FALSE);
2996 default:/* not existing crown (wisdom,lite, etc...) */
3000 break; /* while (1) */
3006 else if (power < -1)
3010 bool ok_flag = TRUE;
3011 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3013 switch (o_ptr->name2)
3015 case EGO_ANCIENT_CURSE:
3016 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3017 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3018 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3019 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3020 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3021 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3025 break; /* while (1) */
3034 if (o_ptr->sval == SV_DRAGON_HELM)
3036 /* Mention the item */
3037 if (cheat_peek) object_mention(o_ptr);
3038 dragon_resist(o_ptr);
3039 if (!one_in_(3)) break;
3045 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3047 create_artifact(o_ptr, FALSE);
3052 bool ok_flag = TRUE;
3053 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3055 switch (o_ptr->name2)
3057 case EGO_BRILLIANCE:
3059 case EGO_INFRAVISION:
3060 case EGO_H_PROTECTION:
3065 if (one_in_(2)) add_esp_strong(o_ptr);
3066 else add_esp_weak(o_ptr, FALSE);
3070 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3071 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3074 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3076 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3078 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3079 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3081 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3082 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3083 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3084 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3085 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3086 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3087 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3088 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3090 default:/* not existing helm (Magi, Might, etc...)*/
3094 break; /* while (1) */
3099 else if (power < -1)
3103 bool ok_flag = TRUE;
3104 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3106 switch (o_ptr->name2)
3108 case EGO_ANCIENT_CURSE:
3112 break; /* while (1) */
3123 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3125 create_artifact(o_ptr, FALSE);
3128 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3130 switch (o_ptr->name2)
3139 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3140 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3141 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3142 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3149 else if (power < -1)
3151 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3161 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3162 * Apply magic to an item known to be a "ring" or "amulet"
3163 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3164 * @param level 生成基準階
3165 * @param power 生成ランク
3168 * Hack -- note special "pval boost" code for ring of speed\n
3169 * Hack -- note that some items must be cursed (or blessed)\n
3171 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3173 /* Apply magic (good or bad) according to type */
3174 switch (o_ptr->tval)
3179 switch (o_ptr->sval)
3181 case SV_RING_ATTACKS:
3184 o_ptr->pval = m_bonus(2, level);
3185 if (one_in_(15)) o_ptr->pval++;
3186 if (o_ptr->pval < 1) o_ptr->pval = 1;
3192 o_ptr->ident |= (IDENT_BROKEN);
3195 o_ptr->curse_flags |= TRC_CURSED;
3198 o_ptr->pval = 0 - (o_ptr->pval);
3209 /* Strength, Constitution, Dexterity, Intelligence */
3215 o_ptr->pval = 1 + m_bonus(5, level);
3221 o_ptr->ident |= (IDENT_BROKEN);
3224 o_ptr->curse_flags |= TRC_CURSED;
3227 o_ptr->pval = 0 - (o_ptr->pval);
3233 /* Ring of Speed! */
3236 /* Base speed (1 to 10) */
3237 o_ptr->pval = randint1(5) + m_bonus(5, level);
3239 /* Super-charge the ring */
3240 while (randint0(100) < 50) o_ptr->pval++;
3246 o_ptr->ident |= (IDENT_BROKEN);
3249 o_ptr->curse_flags |= TRC_CURSED;
3252 o_ptr->pval = 0 - (o_ptr->pval);
3257 /* Mention the item */
3258 if (cheat_peek) object_mention(o_ptr);
3263 case SV_RING_LORDLY:
3267 one_lordly_high_resistance(o_ptr);
3271 /* Bonus to armor class */
3272 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3276 case SV_RING_WARNING:
3278 if (one_in_(3)) one_low_esp(o_ptr);
3283 case SV_RING_SEARCHING:
3285 /* Bonus to searching */
3286 o_ptr->pval = 1 + m_bonus(5, level);
3292 o_ptr->ident |= (IDENT_BROKEN);
3295 o_ptr->curse_flags |= TRC_CURSED;
3298 o_ptr->pval = 0 - (o_ptr->pval);
3304 /* Flames, Acid, Ice */
3305 case SV_RING_FLAMES:
3310 /* Bonus to armor class */
3311 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3315 /* Weakness, Stupidity */
3316 case SV_RING_WEAKNESS:
3317 case SV_RING_STUPIDITY:
3320 o_ptr->ident |= (IDENT_BROKEN);
3323 o_ptr->curse_flags |= TRC_CURSED;
3326 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3327 if (power > 0) power = 0 - power;
3332 /* WOE, Stupidity */
3336 o_ptr->ident |= (IDENT_BROKEN);
3339 o_ptr->curse_flags |= TRC_CURSED;
3342 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3343 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3344 if (power > 0) power = 0 - power;
3349 /* Ring of damage */
3350 case SV_RING_DAMAGE:
3352 /* Bonus to damage */
3353 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3359 o_ptr->ident |= (IDENT_BROKEN);
3362 o_ptr->curse_flags |= TRC_CURSED;
3365 o_ptr->to_d = 0 - o_ptr->to_d;
3371 /* Ring of Accuracy */
3372 case SV_RING_ACCURACY:
3375 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3381 o_ptr->ident |= (IDENT_BROKEN);
3384 o_ptr->curse_flags |= TRC_CURSED;
3387 o_ptr->to_h = 0 - o_ptr->to_h;
3393 /* Ring of Protection */
3394 case SV_RING_PROTECTION:
3396 /* Bonus to armor class */
3397 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3403 o_ptr->ident |= (IDENT_BROKEN);
3406 o_ptr->curse_flags |= TRC_CURSED;
3409 o_ptr->to_a = 0 - o_ptr->to_a;
3415 /* Ring of Slaying */
3416 case SV_RING_SLAYING:
3418 /* Bonus to damage and to hit */
3419 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3420 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3426 o_ptr->ident |= (IDENT_BROKEN);
3429 o_ptr->curse_flags |= TRC_CURSED;
3431 /* Reverse bonuses */
3432 o_ptr->to_h = 0 - o_ptr->to_h;
3433 o_ptr->to_d = 0 - o_ptr->to_d;
3439 case SV_RING_MUSCLE:
3441 o_ptr->pval = 1 + m_bonus(3, level);
3442 if (one_in_(4)) o_ptr->pval++;
3448 o_ptr->ident |= (IDENT_BROKEN);
3451 o_ptr->curse_flags |= TRC_CURSED;
3453 /* Reverse bonuses */
3454 o_ptr->pval = 0 - o_ptr->pval;
3459 case SV_RING_AGGRAVATION:
3462 o_ptr->ident |= (IDENT_BROKEN);
3465 o_ptr->curse_flags |= TRC_CURSED;
3467 if (power > 0) power = 0 - power;
3471 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3472 || (power > 2)) /* power > 2 is debug only */
3474 o_ptr->pval = MIN(o_ptr->pval, 4);
3475 /* Randart amulet */
3476 create_artifact(o_ptr, FALSE);
3478 else if ((power == 2) && one_in_(2))
3480 while(!o_ptr->name2)
3482 int tmp = m_bonus(10, level);
3483 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3484 switch(randint1(28))
3487 o_ptr->name2 = EGO_RING_THROW;
3490 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3491 o_ptr->name2 = EGO_RING_REGEN;
3494 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3495 o_ptr->name2 = EGO_RING_LITE;
3498 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3499 o_ptr->name2 = EGO_RING_TELEPORT;
3502 if (o_ptr->to_h) break;
3503 o_ptr->name2 = EGO_RING_TO_H;
3506 if (o_ptr->to_d) break;
3507 o_ptr->name2 = EGO_RING_TO_D;
3510 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3511 o_ptr->name2 = EGO_RING_SLAY;
3514 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3515 o_ptr->name2 = EGO_RING_WIZARD;
3518 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3519 o_ptr->name2 = EGO_RING_HERO;
3522 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3523 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3524 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3525 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3528 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3529 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;
3530 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3531 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3532 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3535 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3536 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;
3537 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3538 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3539 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3542 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3543 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;
3544 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3545 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3548 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3549 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;
3550 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3551 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3553 case 21: case 22: case 23: case 24: case 25: case 26:
3554 switch (o_ptr->sval)
3557 if (!one_in_(3)) break;
3558 o_ptr->name2 = EGO_RING_D_SPEED;
3560 case SV_RING_DAMAGE:
3561 case SV_RING_ACCURACY:
3562 case SV_RING_SLAYING:
3563 if (one_in_(2)) break;
3564 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3567 o_ptr->name2 = EGO_RING_BERSERKER;
3568 o_ptr->to_h -= 2+randint1(4);
3569 o_ptr->to_d += 2+randint1(4);
3572 case SV_RING_PROTECTION:
3573 o_ptr->name2 = EGO_RING_SUPER_AC;
3574 o_ptr->to_a += 7 + m_bonus(5, level);
3576 case SV_RING_RES_FEAR:
3577 o_ptr->name2 = EGO_RING_HERO;
3580 if (one_in_(2)) break;
3581 o_ptr->name2 = EGO_RING_HUNTER;
3583 case SV_RING_SEARCHING:
3584 o_ptr->name2 = EGO_RING_STEALTH;
3586 case SV_RING_TELEPORTATION:
3587 o_ptr->name2 = EGO_RING_TELE_AWAY;
3589 case SV_RING_RES_BLINDNESS:
3591 o_ptr->name2 = EGO_RING_RES_LITE;
3593 o_ptr->name2 = EGO_RING_RES_DARK;
3595 case SV_RING_LORDLY:
3596 if (!one_in_(20)) break;
3597 one_lordly_high_resistance(o_ptr);
3598 one_lordly_high_resistance(o_ptr);
3599 o_ptr->name2 = EGO_RING_TRUE;
3601 case SV_RING_SUSTAIN:
3602 if (!one_in_(4)) break;
3603 o_ptr->name2 = EGO_RING_RES_TIME;
3605 case SV_RING_FLAMES:
3606 if (!one_in_(2)) break;
3607 o_ptr->name2 = EGO_RING_DRAGON_F;
3610 if (!one_in_(2)) break;
3611 o_ptr->name2 = EGO_RING_DRAGON_C;
3613 case SV_RING_WARNING:
3614 if (!one_in_(2)) break;
3615 o_ptr->name2 = EGO_RING_M_DETECT;
3624 o_ptr->curse_flags = 0L;
3626 else if ((power == -2) && one_in_(2))
3628 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3629 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3630 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3631 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3632 o_ptr->art_flags[0] = 0;
3633 o_ptr->art_flags[1] = 0;
3634 while(!o_ptr->name2)
3636 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3640 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3641 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3644 o_ptr->name2 = EGO_RING_NO_MELEE;
3647 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3648 o_ptr->name2 = EGO_RING_AGGRAVATE;
3651 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3652 o_ptr->name2 = EGO_RING_TY_CURSE;
3655 o_ptr->name2 = EGO_RING_ALBINO;
3660 o_ptr->ident |= (IDENT_BROKEN);
3663 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3671 switch (o_ptr->sval)
3673 /* Amulet of wisdom/charisma */
3674 case SV_AMULET_INTELLIGENCE:
3675 case SV_AMULET_WISDOM:
3676 case SV_AMULET_CHARISMA:
3678 o_ptr->pval = 1 + m_bonus(5, level);
3684 o_ptr->ident |= (IDENT_BROKEN);
3687 o_ptr->curse_flags |= (TRC_CURSED);
3689 /* Reverse bonuses */
3690 o_ptr->pval = 0 - o_ptr->pval;
3696 /* Amulet of brilliance */
3697 case SV_AMULET_BRILLIANCE:
3699 o_ptr->pval = 1 + m_bonus(3, level);
3700 if (one_in_(4)) o_ptr->pval++;
3706 o_ptr->ident |= (IDENT_BROKEN);
3709 o_ptr->curse_flags |= (TRC_CURSED);
3711 /* Reverse bonuses */
3712 o_ptr->pval = 0 - o_ptr->pval;
3718 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3722 o_ptr->curse_flags |= (TRC_CURSED);
3727 case SV_AMULET_RESISTANCE:
3729 if (one_in_(5)) one_high_resistance(o_ptr);
3730 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3734 /* Amulet of searching */
3735 case SV_AMULET_SEARCHING:
3737 o_ptr->pval = randint1(2) + m_bonus(4, level);
3743 o_ptr->ident |= (IDENT_BROKEN);
3746 o_ptr->curse_flags |= (TRC_CURSED);
3748 /* Reverse bonuses */
3749 o_ptr->pval = 0 - (o_ptr->pval);
3755 /* Amulet of the Magi -- never cursed */
3756 case SV_AMULET_THE_MAGI:
3758 o_ptr->pval = randint1(5) + m_bonus(5, level);
3759 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3761 /* gain one low ESP */
3762 add_esp_weak(o_ptr, FALSE);
3764 /* Mention the item */
3765 if (cheat_peek) object_mention(o_ptr);
3770 /* Amulet of Doom -- always cursed */
3771 case SV_AMULET_DOOM:
3774 o_ptr->ident |= (IDENT_BROKEN);
3777 o_ptr->curse_flags |= (TRC_CURSED);
3780 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3781 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3782 if (power > 0) power = 0 - power;
3787 case SV_AMULET_MAGIC_MASTERY:
3789 o_ptr->pval = 1 + m_bonus(4, level);
3795 o_ptr->ident |= (IDENT_BROKEN);
3798 o_ptr->curse_flags |= (TRC_CURSED);
3800 /* Reverse bonuses */
3801 o_ptr->pval = 0 - o_ptr->pval;
3807 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3808 || (power > 2)) /* power > 2 is debug only */
3810 o_ptr->pval = MIN(o_ptr->pval, 4);
3811 /* Randart amulet */
3812 create_artifact(o_ptr, FALSE);
3814 else if ((power == 2) && one_in_(2))
3816 while(!o_ptr->name2)
3818 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3819 switch(randint1(21))
3822 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3823 o_ptr->name2 = EGO_AMU_SLOW_D;
3826 if (o_ptr->pval) break;
3827 o_ptr->name2 = EGO_AMU_INFRA;
3830 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3831 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3834 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3835 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3838 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3839 o_ptr->name2 = EGO_AMU_LEVITATION;
3841 case 10: case 11: case 21:
3842 o_ptr->name2 = EGO_AMU_AC;
3845 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3846 if (m_bonus(10, level) > 8)
3847 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3849 o_ptr->name2 = EGO_AMU_RES_FIRE;
3852 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3853 if (m_bonus(10, level) > 8)
3854 o_ptr->name2 = EGO_AMU_RES_COLD_;
3856 o_ptr->name2 = EGO_AMU_RES_COLD;
3859 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3860 if (m_bonus(10, level) > 8)
3861 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3863 o_ptr->name2 = EGO_AMU_RES_ELEC;
3866 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3867 if (m_bonus(10, level) > 8)
3868 o_ptr->name2 = EGO_AMU_RES_ACID_;
3870 o_ptr->name2 = EGO_AMU_RES_ACID;
3872 case 16: case 17: case 18: case 19: case 20:
3873 switch (o_ptr->sval)
3875 case SV_AMULET_TELEPORT:
3876 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3877 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3878 else o_ptr->name2 = EGO_AMU_TELEPORT;
3880 case SV_AMULET_RESIST_ACID:
3881 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3883 case SV_AMULET_SEARCHING:
3884 o_ptr->name2 = EGO_AMU_STEALTH;
3886 case SV_AMULET_BRILLIANCE:
3887 if (!one_in_(3)) break;
3888 o_ptr->name2 = EGO_AMU_IDENT;
3890 case SV_AMULET_CHARISMA:
3891 if (!one_in_(3)) break;
3892 o_ptr->name2 = EGO_AMU_CHARM;
3894 case SV_AMULET_THE_MAGI:
3895 if (one_in_(2)) break;
3896 o_ptr->name2 = EGO_AMU_GREAT;
3898 case SV_AMULET_RESISTANCE:
3899 if (!one_in_(5)) break;
3900 o_ptr->name2 = EGO_AMU_DEFENDER;
3902 case SV_AMULET_TELEPATHY:
3903 if (!one_in_(3)) break;
3904 o_ptr->name2 = EGO_AMU_DETECTION;
3910 o_ptr->curse_flags = 0L;
3912 else if ((power == -2) && one_in_(2))
3914 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3915 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3916 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3917 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3918 o_ptr->art_flags[0] = 0;
3919 o_ptr->art_flags[1] = 0;
3920 while(!o_ptr->name2)
3922 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3926 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3927 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3930 o_ptr->name2 = EGO_AMU_FOOL;
3933 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3934 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3937 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3938 o_ptr->name2 = EGO_AMU_TY_CURSE;
3941 o_ptr->name2 = EGO_AMU_NAIVETY;
3946 o_ptr->ident |= (IDENT_BROKEN);
3949 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3957 * @brief モンスターが人形のベースにできるかを返す
3958 * @param r_idx チェックしたいモンスター種族のID
3959 * @return 人形にできるならTRUEを返す
3961 static bool item_monster_okay(int r_idx)
3963 monster_race *r_ptr = &r_info[r_idx];
3966 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3967 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3968 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3969 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3970 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3971 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3979 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3980 * Apply magic to an item known to be "boring"
3981 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3982 * @param level 生成基準階
3983 * @param power 生成ランク
3986 * Hack -- note the special code for various items
3988 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3990 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3995 /* Apply magic (good or bad) according to type */
3996 switch (o_ptr->tval)
4005 o_ptr->ident |= (IDENT_BROKEN);
4008 o_ptr->curse_flags |= (TRC_CURSED);
4015 o_ptr->xtra4 = o_ptr->pval;
4021 /* Hack -- Torches -- random fuel */
4022 if (o_ptr->sval == SV_LITE_TORCH)
4024 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4028 /* Hack -- Lanterns -- random fuel */
4029 if (o_ptr->sval == SV_LITE_LANTERN)
4031 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4035 if (power > 2) /* power > 2 is debug only */
4037 create_artifact(o_ptr, FALSE);
4039 else if ((power == 2) || ((power == 1) && one_in_(3)))
4041 while (!o_ptr->name2)
4045 bool okay_flag = TRUE;
4047 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4049 switch (o_ptr->name2)
4052 if (o_ptr->sval == SV_LITE_FEANOR)
4060 else if (power == -2)
4062 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4064 switch (o_ptr->name2)
4066 case EGO_LITE_DARKNESS:
4069 if (o_ptr->sval == SV_LITE_TORCH)
4071 add_flag(o_ptr->art_flags, TR_LITE_M1);
4073 else if (o_ptr->sval == SV_LITE_LANTERN)
4075 add_flag(o_ptr->art_flags, TR_LITE_M2);
4077 else if (o_ptr->sval == SV_LITE_FEANOR)
4079 add_flag(o_ptr->art_flags, TR_LITE_M3);
4091 /* The wand or staff gets a number of initial charges equal
4092 * to between 1/2 (+1) and the full object kind's pval. -LM-
4094 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4100 /* Transfer the pval. -LM- */
4101 o_ptr->pval = k_ptr->pval;
4108 object_aware(o_ptr);
4109 object_known(o_ptr);
4118 monster_race *r_ptr;
4120 /* Pick a random non-unique monster race */
4123 i = randint1(max_r_idx - 1);
4125 if (!item_monster_okay(i)) continue;
4126 if (i == MON_TSUCHINOKO) continue;
4130 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4132 /* Ignore dead monsters */
4133 if (!r_ptr->rarity) continue;
4135 /* Ignore uncommon monsters */
4136 if (r_ptr->rarity > 100) continue;
4138 /* Prefer less out-of-depth monsters */
4139 if (randint0(check)) continue;
4146 /* Some figurines are cursed */
4147 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4151 msg_format(_("%sの人形, 深さ +%d%s", "Figurine of %s, depth +%d%s"),
4152 r_name + r_ptr->name, check - 1,
4153 !object_is_cursed(o_ptr) ? "" : " {cursed}");
4166 monster_race *r_ptr;
4168 if (o_ptr->sval == SV_SKELETON)
4170 match = RF9_DROP_SKELETON;
4172 else if (o_ptr->sval == SV_CORPSE)
4174 match = RF9_DROP_CORPSE;
4177 /* Hack -- Remove the monster restriction */
4178 get_mon_num_prep(item_monster_okay, NULL);
4180 /* Pick a random non-unique monster race */
4183 i = get_mon_num(dun_level);
4187 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4189 /* Ignore dead monsters */
4190 if (!r_ptr->rarity) continue;
4192 /* Ignore corpseless monsters */
4193 if (!(r_ptr->flags9 & match)) continue;
4195 /* Prefer less out-of-depth monsters */
4196 if (randint0(check)) continue;
4205 msg_format(_("%sの死体, 深さ +%d", "Corpse of %s, depth +%d"),
4206 r_name + r_ptr->name, check - 1);
4209 object_aware(o_ptr);
4210 object_known(o_ptr);
4218 monster_race *r_ptr;
4220 /* Pick a random monster race */
4223 i = randint1(max_r_idx - 1);
4227 /* Ignore dead monsters */
4228 if (!r_ptr->rarity) continue;
4237 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4239 object_aware(o_ptr);
4240 object_known(o_ptr);
4247 byte obj_level = k_info[o_ptr->k_idx].level;
4249 /* Hack -- skip ruined chests */
4250 if (obj_level <= 0) break;
4252 /* Hack -- pick a "difficulty" */
4253 o_ptr->pval = randint1(obj_level);
4254 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4256 o_ptr->xtra3 = dun_level + 5;
4258 /* Never exceed "difficulty" of 55 to 59 */
4259 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4267 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4268 * Complete the "creation" of an object by applying "magic" to the item
4269 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4271 * @param mode 生成オプション
4274 * This includes not only rolling for random bonuses, but also putting the\n
4275 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4276 * staffs, giving fuel to lites, and placing traps on chests.\n
4278 * In particular, note that "Instant Artifacts", if "created" by an external\n
4279 * routine, must pass through this function to complete the actual creation.\n
4281 * The base "chance" of the item being "good" increases with the "level"\n
4282 * parameter, which is usually derived from the dungeon level, being equal\n
4283 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4284 * the object is guaranteed to be "good". If an object is "good", then\n
4285 * the chance that the object will be "great" (ego-item or artifact), also\n
4286 * increases with the "level", being equal to half the level, plus 5, up to\n
4287 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4288 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4290 * If the object is not "good", there is a chance it will be "cursed", and\n
4291 * if it is "cursed", there is a chance it will be "broken". These chances\n
4292 * are related to the "good" / "great" chances above.\n
4294 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4295 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4297 * If "okay" is true, and the object is going to be "great", then there is\n
4298 * a chance that an artifact will be created. This is true even if both the\n
4299 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4300 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4302 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4304 int i, rolls, f1, f2, power;
4306 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4308 /* Maximum "level" for various things */
4309 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4311 /* Base chance of being "good" */
4314 /* Maximal chance of being "good" */
4315 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4317 /* Base chance of being "great" */
4320 /* Maximal chance of being "great" */
4321 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4322 f2 = d_info[dungeon_type].obj_great;
4324 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4329 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4338 /* Roll for "good" */
4339 if ((mode & AM_GOOD) || magik(f1))
4344 /* Roll for "great" */
4345 if ((mode & AM_GREAT) || magik(f2))
4349 /* Roll for "special" */
4350 if (mode & AM_SPECIAL) power = 3;
4354 /* Roll for "cursed" */
4357 /* Assume "cursed" */
4360 /* Roll for "broken" */
4361 if (magik(f2)) power = -2;
4365 if (mode & AM_CURSED)
4367 /* Assume 'cursed' */
4372 /* Everything else gets more badly cursed */
4379 /* Assume no rolls */
4382 /* Get one roll if excellent */
4383 if (power >= 2) rolls = 1;
4385 /* Hack -- Get four rolls if forced great or special */
4386 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4388 /* Hack -- Get no rolls if not allowed */
4389 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4391 /* Roll for artifacts if allowed */
4392 for (i = 0; i < rolls; i++)
4394 /* Roll for an artifact */
4395 if (make_artifact(o_ptr)) break;
4396 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4398 if (make_artifact(o_ptr)) break;
4403 /* Hack -- analyze artifacts */
4404 if (object_is_fixed_artifact(o_ptr))
4406 artifact_type *a_ptr = &a_info[o_ptr->name1];
4408 /* Hack -- Mark the artifact as "created" */
4411 /* Hack -- Memorize location of artifact in saved floors */
4412 if (character_dungeon)
4413 a_ptr->floor_id = p_ptr->floor_id;
4415 /* Extract the other fields */
4416 o_ptr->pval = a_ptr->pval;
4417 o_ptr->ac = a_ptr->ac;
4418 o_ptr->dd = a_ptr->dd;
4419 o_ptr->ds = a_ptr->ds;
4420 o_ptr->to_a = a_ptr->to_a;
4421 o_ptr->to_h = a_ptr->to_h;
4422 o_ptr->to_d = a_ptr->to_d;
4423 o_ptr->weight = a_ptr->weight;
4424 o_ptr->xtra2 = a_ptr->act_idx;
4426 if (o_ptr->name1 == ART_MILIM)
4428 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4434 /* Hack -- extract the "broken" flag */
4435 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4437 /* Hack -- extract the "cursed" flag */
4438 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4439 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4440 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4441 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4442 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4443 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4446 /* Cheat -- peek at the item */
4447 if (cheat_peek) object_mention(o_ptr);
4455 switch (o_ptr->tval)
4464 if (power) a_m_aux_1(o_ptr, lev, power);
4470 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4476 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4490 /* Elven Cloak and Black Clothes ... */
4491 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4492 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4493 o_ptr->pval = randint1(4);
4497 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4498 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4499 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4500 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4501 a_m_aux_2(o_ptr, lev, power);
4503 if (power) a_m_aux_2(o_ptr, lev, power);
4511 if (!power && (randint0(100) < 50)) power = -1;
4512 a_m_aux_3(o_ptr, lev, power);
4518 a_m_aux_4(o_ptr, lev, power);
4523 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4524 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4525 (p_ptr->pseikaku == SEIKAKU_SEXY))
4528 add_flag(o_ptr->art_flags, TR_STR);
4529 add_flag(o_ptr->art_flags, TR_INT);
4530 add_flag(o_ptr->art_flags, TR_WIS);
4531 add_flag(o_ptr->art_flags, TR_DEX);
4532 add_flag(o_ptr->art_flags, TR_CON);
4533 add_flag(o_ptr->art_flags, TR_CHR);
4536 /* Hack -- analyze ego-items */
4537 if (object_is_ego(o_ptr))
4539 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4541 /* Hack -- acquire "broken" flag */
4542 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4544 /* Hack -- acquire "cursed" flag */
4545 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4546 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4547 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4548 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4549 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4550 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4552 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4553 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4554 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4555 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4556 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4557 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4558 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4559 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4565 while (one_in_(o_ptr->dd));
4567 if (o_ptr->dd > 9) o_ptr->dd = 9;
4570 /* Hack -- apply activatin index if needed */
4571 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4573 /* Hack -- apply extra penalties if needed */
4574 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4576 /* Hack -- obtain bonuses */
4577 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4578 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4579 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4581 /* Hack -- obtain pval */
4582 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4585 /* Hack -- apply extra bonuses if needed */
4588 /* Hack -- obtain bonuses */
4589 if (e_ptr->max_to_h)
4591 if (e_ptr->max_to_h > 127)
4592 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4593 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4595 if (e_ptr->max_to_d)
4597 if (e_ptr->max_to_d > 127)
4598 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4599 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4601 if (e_ptr->max_to_a)
4603 if (e_ptr->max_to_a > 127)
4604 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4605 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4608 /* Accuracy ego must have high to_h */
4609 if(o_ptr->name2 == EGO_ACCURACY)
4611 while(o_ptr->to_h < o_ptr->to_d + 10)
4616 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4619 /* Accuracy ego must have high to_h */
4620 if(o_ptr->name2 == EGO_VELOCITY)
4622 while(o_ptr->to_d < o_ptr->to_h + 10)
4627 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4630 /* Protection ego must have high to_a */
4631 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4633 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4636 /* Hack -- obtain pval */
4637 if (e_ptr->max_pval)
4639 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4642 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4644 else if (o_ptr->name2 == EGO_DEMON)
4646 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4648 o_ptr->pval += randint1(2);
4652 o_ptr->pval += randint1(e_ptr->max_pval);
4655 else if (o_ptr->name2 == EGO_ATTACKS)
4657 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4658 if (o_ptr->pval > 3) o_ptr->pval = 3;
4659 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4660 o_ptr->pval += randint1(2);
4662 else if (o_ptr->name2 == EGO_BAT)
4664 o_ptr->pval = randint1(e_ptr->max_pval);
4665 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4667 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4669 o_ptr->pval = randint1(e_ptr->max_pval);
4673 o_ptr->pval += randint1(e_ptr->max_pval);
4678 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4680 o_ptr->pval = randint1(o_ptr->pval);
4682 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4686 /* Cheat -- describe the item */
4687 if (cheat_peek) object_mention(o_ptr);
4693 /* Examine real objects */
4696 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4698 /* Hack -- acquire "broken" flag */
4699 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4701 /* Hack -- acquire "cursed" flag */
4702 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4703 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4704 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4705 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4706 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4707 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4713 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4714 * Hack -- determine if a template is "good"
4715 * @param k_idx 判定したいベースアイテムのID
4716 * @return ベースアイテムが上質ならばTRUEを返す。
4718 static bool kind_is_good(int k_idx)
4720 object_kind *k_ptr = &k_info[k_idx];
4722 /* Analyze the item type */
4723 switch (k_ptr->tval)
4725 /* Armor -- Good unless damaged */
4736 if (k_ptr->to_a < 0) return (FALSE);
4740 /* Weapons -- Good unless damaged */
4747 if (k_ptr->to_h < 0) return (FALSE);
4748 if (k_ptr->to_d < 0) return (FALSE);
4752 /* Ammo -- Arrows/Bolts are good */
4759 /* Books -- High level books are good (except Arcane books) */
4761 case TV_SORCERY_BOOK:
4762 case TV_NATURE_BOOK:
4767 case TV_DAEMON_BOOK:
4768 case TV_CRUSADE_BOOK:
4770 case TV_HISSATSU_BOOK:
4773 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4777 /* Rings -- Rings of Speed are good */
4780 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4781 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4785 /* Amulets -- Amulets of the Magi and Resistance are good */
4788 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4789 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4794 /* Assume not good */
4799 * @brief 生成階に応じたベースアイテムの生成を行う。
4800 * Attempt to make an object (normal or good/great)
4801 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4802 * @param mode オプションフラグ
4803 * @return 生成に成功したらTRUEを返す。
4805 * This routine plays nasty games to generate the "special artifacts".\n
4806 * This routine uses "object_level" for the "generation level".\n
4807 * We assume that the given object has been "wiped".\n
4809 bool make_object(object_type *j_ptr, u32b mode)
4815 /* Chance of "special object" */
4816 prob = ((mode & AM_GOOD) ? 10 : 1000);
4818 /* Base level for the object */
4819 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4822 /* Generate a special object, or a normal object */
4823 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4828 if ((mode & AM_GOOD) && !get_obj_num_hook)
4830 /* Activate restriction (if already specified, use that) */
4831 get_obj_num_hook = kind_is_good;
4834 /* Restricted objects - prepare allocation table */
4835 if (get_obj_num_hook) get_obj_num_prep();
4837 /* Pick a random object */
4838 k_idx = get_obj_num(base);
4840 /* Restricted objects */
4841 if (get_obj_num_hook)
4843 /* Clear restriction */
4844 get_obj_num_hook = NULL;
4846 /* Reset allocation table to default */
4850 /* Handle failure */
4851 if (!k_idx) return (FALSE);
4853 /* Prepare the object */
4854 object_prep(j_ptr, k_idx);
4857 /* Apply magic (allow artifacts) */
4858 apply_magic(j_ptr, object_level, mode);
4860 /* Hack -- generate multiple spikes/missiles */
4861 switch (j_ptr->tval)
4869 j_ptr->number = (byte)damroll(6, 7);
4873 obj_level = k_info[j_ptr->k_idx].level;
4874 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4876 /* Notice "okay" out-of-depth objects */
4877 if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
4878 (obj_level > dun_level))
4880 /* Cheat -- peek at items */
4881 if (cheat_peek) object_mention(j_ptr);
4890 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4891 * Attempt to place an object (normal or good/great) at the given location.
4892 * @param y 配置したいフロアのY座標
4893 * @param x 配置したいフロアのX座標
4894 * @param mode オプションフラグ
4895 * @return 生成に成功したらTRUEを返す。
4897 * This routine plays nasty games to generate the "special artifacts".\n
4898 * This routine uses "object_level" for the "generation level".\n
4899 * This routine requires a clean floor grid destination.\n
4901 void place_object(int y, int x, u32b mode)
4906 cave_type *c_ptr = &cave[y][x];
4912 /* Paranoia -- check bounds */
4913 if (!in_bounds(y, x)) return;
4915 /* Require floor space */
4916 if (!cave_drop_bold(y, x)) return;
4918 /* Avoid stacking on other objects */
4919 if (c_ptr->o_idx) return;
4922 /* Get local object */
4925 /* Wipe the object */
4928 /* Make an object (if possible) */
4929 if (!make_object(q_ptr, mode)) return;
4932 /* Make an object */
4940 /* Acquire object */
4941 o_ptr = &o_list[o_idx];
4943 /* Structure Copy */
4944 object_copy(o_ptr, q_ptr);
4951 o_ptr->next_o_idx = c_ptr->o_idx;
4953 /* Place the object */
4954 c_ptr->o_idx = o_idx;
4964 /* Hack -- Preserve artifacts */
4965 if (object_is_fixed_artifact(q_ptr))
4967 a_info[q_ptr->name1].cur_num = 0;
4974 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4975 * Make a treasure object
4976 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4977 * @return 生成に成功したらTRUEを返す。
4979 * The location must be a legal, clean, floor grid.
4981 bool make_gold(object_type *j_ptr)
4988 /* Hack -- Pick a Treasure variety */
4989 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4991 /* Apply "extra" magic */
4992 if (one_in_(GREAT_OBJ))
4994 i += randint1(object_level + 1);
4997 /* Hack -- Creeping Coins only generate "themselves" */
4998 if (coin_type) i = coin_type;
5000 /* Do not create "illegal" Treasure Types */
5001 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
5003 /* Prepare a gold object */
5004 object_prep(j_ptr, OBJ_GOLD_LIST + i);
5006 /* Hack -- Base coin cost */
5007 base = k_info[OBJ_GOLD_LIST+i].cost;
5009 /* Determine how much the treasure is "worth" */
5010 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5018 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
5019 * Places a treasure (Gold or Gems) at given location
5020 * @param y 配置したいフロアのY座標
5021 * @param x 配置したいフロアのX座標
5022 * @return 生成に成功したらTRUEを返す。
5024 * The location must be a legal, clean, floor grid.
5026 void place_gold(int y, int x)
5031 cave_type *c_ptr = &cave[y][x];
5038 /* Paranoia -- check bounds */
5039 if (!in_bounds(y, x)) return;
5041 /* Require floor space */
5042 if (!cave_drop_bold(y, x)) return;
5044 /* Avoid stacking on other objects */
5045 if (c_ptr->o_idx) return;
5048 /* Get local object */
5051 /* Wipe the object */
5054 /* Make some gold */
5055 if (!make_gold(q_ptr)) return;
5058 /* Make an object */
5066 /* Acquire object */
5067 o_ptr = &o_list[o_idx];
5069 /* Copy the object */
5070 object_copy(o_ptr, q_ptr);
5077 o_ptr->next_o_idx = c_ptr->o_idx;
5079 /* Place the object */
5080 c_ptr->o_idx = o_idx;
5092 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5093 * Let an object fall to the ground at or near a location.
5094 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5095 * @param chance ドロップの成功率(%)
5096 * @param y 配置したいフロアのY座標
5097 * @param x 配置したいフロアのX座標
5098 * @return 生成に成功したらTRUEを返す。
5100 * The initial location is assumed to be "in_bounds()".\n
5102 * This function takes a parameter "chance". This is the percentage\n
5103 * chance that the item will "disappear" instead of drop. If the object\n
5104 * has been thrown, then this is the chance of disappearance on contact.\n
5106 * Hack -- this function uses "chance" to determine if it should produce\n
5107 * some form of "description" of the drop event (under the player).\n
5109 * We check several locations to see if we can find a location at which\n
5110 * the object can combine, stack, or be placed. Artifacts will try very\n
5111 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5113 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5124 s16b this_o_idx, next_o_idx = 0;
5128 char o_name[MAX_NLEN];
5134 /* Extract plural */
5135 bool plural = (j_ptr->number != 1);
5138 /* Describe object */
5139 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5142 /* Handle normal "breakage" */
5143 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5147 msg_format("%sは消えた。", o_name);
5149 msg_format("The %s disappear%s.",
5150 o_name, (plural ? "" : "s"));
5155 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5172 /* Scan local grids */
5173 for (dy = -3; dy <= 3; dy++)
5175 /* Scan local grids */
5176 for (dx = -3; dx <= 3; dx++)
5180 /* Calculate actual distance */
5181 d = (dy * dy) + (dx * dx);
5183 /* Ignore distant grids */
5184 if (d > 10) continue;
5190 /* Skip illegal grids */
5191 if (!in_bounds(ty, tx)) continue;
5193 /* Require line of projection */
5194 if (!projectable(y, x, ty, tx)) continue;
5197 c_ptr = &cave[ty][tx];
5199 /* Require floor space */
5200 if (!cave_drop_bold(ty, tx)) continue;
5205 /* Scan objects in that grid */
5206 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5210 /* Acquire object */
5211 o_ptr = &o_list[this_o_idx];
5213 /* Acquire next object */
5214 next_o_idx = o_ptr->next_o_idx;
5216 /* Check for possible combination */
5217 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5223 /* Add new object */
5227 if (k > 99) continue;
5229 /* Calculate score */
5230 s = 1000 - (d + k * 5);
5232 /* Skip bad values */
5233 if (s < bs) continue;
5235 /* New best value */
5238 /* Apply the randomizer to equivalent values */
5239 if ((++bn >= 2) && !one_in_(bn)) continue;
5254 /* Handle lack of space */
5255 if (!flag && !object_is_artifact(j_ptr))
5259 msg_format("%sは消えた。", o_name);
5261 msg_format("The %s disappear%s.",
5262 o_name, (plural ? "" : "s"));
5267 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5275 for (i = 0; !flag && (i < 1000); i++)
5278 ty = rand_spread(by, 1);
5279 tx = rand_spread(bx, 1);
5281 /* Verify location */
5282 if (!in_bounds(ty, tx)) continue;
5284 /* Bounce to that location */
5288 /* Require floor space */
5289 if (!cave_drop_bold(by, bx)) continue;
5298 int candidates = 0, pick;
5300 for (ty = 1; ty < cur_hgt - 1; ty++)
5302 for (tx = 1; tx < cur_wid - 1; tx++)
5304 /* A valid space found */
5305 if (cave_drop_bold(ty, tx)) candidates++;
5309 /* No valid place! */
5314 msg_format("%sは消えた。", o_name);
5316 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5320 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5322 /* Mega-Hack -- preserve artifacts */
5325 /* Hack -- Preserve unknown artifacts */
5326 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5328 /* Mega-Hack -- Preserve the artifact */
5329 a_info[j_ptr->name1].cur_num = 0;
5337 /* Choose a random one */
5338 pick = randint1(candidates);
5340 for (ty = 1; ty < cur_hgt - 1; ty++)
5342 for (tx = 1; tx < cur_wid - 1; tx++)
5344 if (cave_drop_bold(ty, tx))
5348 /* Is this a picked one? */
5362 c_ptr = &cave[by][bx];
5364 /* Scan objects in that grid for combination */
5365 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5369 /* Acquire object */
5370 o_ptr = &o_list[this_o_idx];
5372 /* Acquire next object */
5373 next_o_idx = o_ptr->next_o_idx;
5375 /* Check for combination */
5376 if (object_similar(o_ptr, j_ptr))
5378 /* Combine the items */
5379 object_absorb(o_ptr, j_ptr);
5389 /* Get new object */
5390 if (!done) o_idx = o_pop();
5393 if (!done && !o_idx)
5397 msg_format("%sは消えた。", o_name);
5399 msg_format("The %s disappear%s.",
5400 o_name, (plural ? "" : "s"));
5405 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5407 /* Hack -- Preserve artifacts */
5408 if (object_is_fixed_artifact(j_ptr))
5410 a_info[j_ptr->name1].cur_num = 0;
5420 /* Structure copy */
5421 object_copy(&o_list[o_idx], j_ptr);
5423 /* Access new object */
5424 j_ptr = &o_list[o_idx];
5431 j_ptr->held_m_idx = 0;
5434 j_ptr->next_o_idx = c_ptr->o_idx;
5436 /* Place the object */
5437 c_ptr->o_idx = o_idx;
5452 /* Mega-Hack -- no message if "dropped" by player */
5453 /* Message when an object falls under the player */
5454 if (chance && player_bold(by, bx))
5456 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5468 * Scatter some "great" objects near the player
5469 * @param y1 配置したいフロアのY座標
5470 * @param x1 配置したいフロアのX座標
5471 * @param num 獲得の処理回数
5472 * @param great TRUEならば必ず高級品以上を落とす
5473 * @param special TRUEならば必ず特別品を落とす
5474 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5477 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5480 object_type object_type_body;
5481 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5486 /* Get local object */
5487 i_ptr = &object_type_body;
5489 /* Wipe the object */
5492 /* Make a good (or great) object (if possible) */
5493 if (!make_object(i_ptr, mode)) continue;
5497 object_aware(i_ptr);
5498 object_known(i_ptr);
5501 /* Drop the object */
5502 (void)drop_near(i_ptr, -1, y1, x1);
5507 * Scatter some "amusing" objects near the player
5510 #define AMS_NOTHING 0x00 /* No restriction */
5511 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5512 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5513 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5514 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5524 amuse_type amuse_info[] =
5526 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5527 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5528 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5529 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5530 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5531 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5532 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5533 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5534 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5535 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5536 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5537 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5538 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5545 * @param y1 配置したいフロアのY座標
5546 * @param x1 配置したいフロアのX座標
5547 * @param num 誰得の処理回数
5548 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5551 void amusement(int y1, int x1, int num, bool known)
5554 object_type object_type_body;
5557 for (n = 0; amuse_info[n].tval != 0; n++)
5559 t += amuse_info[n].prob;
5565 int i, k_idx, a_idx = 0;
5566 int r = randint0(t);
5567 bool insta_art, fixed_art;
5571 r -= amuse_info[i].prob;
5575 /* Get local object */
5576 i_ptr = &object_type_body;
5578 /* Wipe the object */
5581 /* Wipe the object */
5582 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5584 /* Paranoia - reroll if nothing */
5585 if (!k_idx) continue;
5587 /* Search an artifact index if need */
5588 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5589 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5591 if (insta_art || fixed_art)
5593 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5595 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5596 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5597 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5598 if (a_info[a_idx].cur_num > 0) continue;
5602 if (a_idx >= max_a_idx) continue;
5605 /* Make an object (if possible) */
5606 object_prep(i_ptr, k_idx);
5607 if (a_idx) i_ptr->name1 = a_idx;
5608 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5610 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5612 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5615 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5616 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5620 object_aware(i_ptr);
5621 object_known(i_ptr);
5624 /* Paranoia - reroll if nothing */
5625 if (!(i_ptr->k_idx)) continue;
5627 /* Drop the object */
5628 (void)drop_near(i_ptr, -1, y1, x1);
5635 #define MAX_NORMAL_TRAPS 18
5637 /* See init_feat_variables() in init2.c */
5638 static s16b normal_traps[MAX_NORMAL_TRAPS];
5641 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5644 void init_normal_traps(void)
5648 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5649 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5650 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5651 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5652 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5653 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5654 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5655 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5656 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5657 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5658 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5659 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5660 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5661 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5662 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5663 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5664 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5665 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5669 * @brief 基本トラップをランダムに選択する /
5671 * @return 選択したトラップのID
5673 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5674 * That is, it does not make sense to have spiked pits at 50 feet.\n
5675 * Actually, it is not this routine, but the "trap instantiation"\n
5676 * code, which should also check for "trap doors" on quest levels.\n
5678 s16b choose_random_trap(void)
5685 /* Hack -- pick a trap */
5686 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5688 /* Accept non-trapdoors */
5689 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5691 /* Hack -- no trap doors on special levels */
5692 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5694 /* Hack -- no trap doors on the deepest level */
5695 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5704 * @brief マスに存在するトラップを秘匿する /
5705 * Disclose an invisible trap
5706 * @param y 秘匿したいマスのY座標
5707 * @param x 秘匿したいマスのX座標
5710 void disclose_grid(int y, int x)
5712 cave_type *c_ptr = &cave[y][x];
5714 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5716 /* No longer hidden */
5717 cave_alter_feat(y, x, FF_SECRET);
5719 else if (c_ptr->mimic)
5721 /* No longer hidden */
5733 * @brief マスをトラップを配置する /
5734 * The location must be a legal, naked, floor grid.
5735 * @param y 配置したいマスのY座標
5736 * @param x 配置したいマスのX座標
5738 * Note that all traps start out as "invisible" and "untyped", and then\n
5739 * when they are "discovered" (by detecting them or setting them off),\n
5740 * the trap is "instantiated" as a visible, "typed", trap.\n
5742 void place_trap(int y, int x)
5744 cave_type *c_ptr = &cave[y][x];
5746 /* Paranoia -- verify location */
5747 if (!in_bounds(y, x)) return;
5749 /* Require empty, clean, floor grid */
5750 if (!cave_clean_bold(y, x)) return;
5752 /* Place an invisible trap */
5753 c_ptr->mimic = c_ptr->feat;
5754 c_ptr->feat = choose_random_trap();
5758 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5759 * Describe the charges on an item in the inventory.
5760 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5763 void inven_item_charges(int item)
5765 object_type *o_ptr = &inventory[item];
5767 /* Require staff/wand */
5768 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5770 /* Require known item */
5771 if (!object_is_known(o_ptr)) return;
5774 if (o_ptr->pval <= 0)
5776 msg_print("もう魔力が残っていない。");
5780 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5783 /* Multiple charges */
5784 if (o_ptr->pval != 1)
5786 /* Print a message */
5787 msg_format("You have %d charges remaining.", o_ptr->pval);
5793 /* Print a message */
5794 msg_format("You have %d charge remaining.", o_ptr->pval);
5801 * @brief アイテムの残り所持数メッセージを表示する /
5802 * Describe an item in the inventory.
5803 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5806 void inven_item_describe(int item)
5808 object_type *o_ptr = &inventory[item];
5809 char o_name[MAX_NLEN];
5811 /* Get a description */
5812 object_desc(o_name, o_ptr, 0);
5814 /* Print a message */
5816 /* "no more" の場合はこちらで表示する */
5817 if (o_ptr->number <= 0)
5819 /*FIRST*//*ここはもう通らないかも */
5820 msg_format("もう%sを持っていない。", o_name);
5824 /* アイテム名を英日切り替え機能対応 */
5825 msg_format("まだ %sを持っている。", o_name);
5828 msg_format("You have %s.", o_name);
5834 * @brief アイテムの残り所持数メッセージを表示する /
5835 * Increase the "number" of an item in the inventory
5836 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5840 void inven_item_increase(int item, int num)
5842 object_type *o_ptr = &inventory[item];
5845 num += o_ptr->number;
5848 if (num > 255) num = 255;
5849 else if (num < 0) num = 0;
5852 num -= o_ptr->number;
5854 /* Change the number and weight */
5857 /* Add the number */
5858 o_ptr->number += num;
5860 /* Add the weight */
5861 p_ptr->total_weight += (num * o_ptr->weight);
5863 /* Recalculate bonuses */
5864 p_ptr->update |= (PU_BONUS);
5866 /* Recalculate mana XXX */
5867 p_ptr->update |= (PU_MANA);
5869 /* Combine the pack */
5870 p_ptr->notice |= (PN_COMBINE);
5873 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5875 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5876 if (!o_ptr->number && p_ptr->ele_attack)
5878 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5880 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5882 /* Clear all temporary elemental brands */
5883 set_ele_attack(0, 0);
5891 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5892 * Erase an inventory slot if it has no more items
5893 * @param item 消去したいプレイヤーのアイテム所持スロット
5896 void inven_item_optimize(int item)
5898 object_type *o_ptr = &inventory[item];
5900 /* Only optimize real items */
5901 if (!o_ptr->k_idx) return;
5903 /* Only optimize empty items */
5904 if (o_ptr->number) return;
5906 /* The item is in the pack */
5907 if (item < INVEN_RARM)
5914 /* Slide everything down */
5915 for (i = item; i < INVEN_PACK; i++)
5917 /* Structure copy */
5918 inventory[i] = inventory[i+1];
5921 /* Erase the "final" slot */
5922 object_wipe(&inventory[i]);
5925 p_ptr->window |= (PW_INVEN);
5928 /* The item is being wielded */
5934 /* Erase the empty slot */
5935 object_wipe(&inventory[item]);
5937 /* Recalculate bonuses */
5938 p_ptr->update |= (PU_BONUS);
5940 /* Recalculate torch */
5941 p_ptr->update |= (PU_TORCH);
5943 /* Recalculate mana XXX */
5944 p_ptr->update |= (PU_MANA);
5947 p_ptr->window |= (PW_EQUIP);
5951 p_ptr->window |= (PW_SPELL);
5955 * @brief 床上の魔道具の残り残量メッセージを表示する /
5956 * Describe the charges on an item on the floor.
5957 * @param item メッセージの対象にしたいアイテム所持スロット
5960 void floor_item_charges(int item)
5962 object_type *o_ptr = &o_list[item];
5964 /* Require staff/wand */
5965 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5967 /* Require known item */
5968 if (!object_is_known(o_ptr)) return;
5971 if (o_ptr->pval <= 0)
5973 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5977 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5980 /* Multiple charges */
5981 if (o_ptr->pval != 1)
5983 /* Print a message */
5984 msg_format("There are %d charges remaining.", o_ptr->pval);
5990 /* Print a message */
5991 msg_format("There is %d charge remaining.", o_ptr->pval);
5998 * @brief 床上のアイテムの残り数メッセージを表示する /
5999 * Describe the charges on an item on the floor.
6000 * @param item メッセージの対象にしたいアイテム所持スロット
6003 void floor_item_describe(int item)
6005 object_type *o_ptr = &o_list[item];
6006 char o_name[MAX_NLEN];
6008 /* Get a description */
6009 object_desc(o_name, o_ptr, 0);
6011 /* Print a message */
6013 /* "no more" の場合はこちらで表示を分ける */
6014 if (o_ptr->number <= 0)
6016 msg_format("床上には、もう%sはない。", o_name);
6020 msg_format("床上には、まだ %sがある。", o_name);
6023 msg_format("You see %s.", o_name);
6030 * @brief 床上のアイテムの数を増やす /
6031 * Increase the "number" of an item on the floor
6032 * @param item 増やしたいアイテムの所持スロット
6033 * @param num 増やしたいアイテムの数
6036 void floor_item_increase(int item, int num)
6038 object_type *o_ptr = &o_list[item];
6041 num += o_ptr->number;
6044 if (num > 255) num = 255;
6045 else if (num < 0) num = 0;
6048 num -= o_ptr->number;
6050 /* Change the number */
6051 o_ptr->number += num;
6056 * @brief 床上の数の無くなったアイテムスロットを消去する /
6057 * Optimize an item on the floor (destroy "empty" items)
6058 * @param item 消去したいアイテムの所持スロット
6061 void floor_item_optimize(int item)
6063 object_type *o_ptr = &o_list[item];
6065 /* Paranoia -- be sure it exists */
6066 if (!o_ptr->k_idx) return;
6068 /* Only optimize empty items */
6069 if (o_ptr->number) return;
6071 /* Delete the object */
6072 delete_object_idx(item);
6077 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6078 * Check if we have space for an item in the pack without overflow
6079 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6080 * @return 溢れずに済むならTRUEを返す
6082 bool inven_carry_okay(object_type *o_ptr)
6087 if (inven_cnt < INVEN_PACK) return (TRUE);
6090 for (j = 0; j < INVEN_PACK; j++)
6092 object_type *j_ptr = &inventory[j];
6094 /* Skip non-objects */
6095 if (!j_ptr->k_idx) continue;
6097 /* Check if the two items can be combined */
6098 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6106 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6107 * Check if we have space for an item in the pack without overflow
6108 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6109 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6110 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6111 * @return o_ptrの方が上位ならばTRUEを返す。
6113 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6117 /* Use empty slots */
6118 if (!j_ptr->k_idx) return TRUE;
6120 /* Hack -- readable books always come first */
6121 if ((o_ptr->tval == REALM1_BOOK) &&
6122 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6123 if ((j_ptr->tval == REALM1_BOOK) &&
6124 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6126 if ((o_ptr->tval == REALM2_BOOK) &&
6127 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6128 if ((j_ptr->tval == REALM2_BOOK) &&
6129 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6131 /* Objects sort by decreasing type */
6132 if (o_ptr->tval > j_ptr->tval) return TRUE;
6133 if (o_ptr->tval < j_ptr->tval) return FALSE;
6135 /* Non-aware (flavored) items always come last */
6136 /* Can happen in the home */
6137 if (!object_is_aware(o_ptr)) return FALSE;
6138 if (!object_is_aware(j_ptr)) return TRUE;
6140 /* Objects sort by increasing sval */
6141 if (o_ptr->sval < j_ptr->sval) return TRUE;
6142 if (o_ptr->sval > j_ptr->sval) return FALSE;
6144 /* Unidentified objects always come last */
6145 /* Objects in the home can be unknown */
6146 if (!object_is_known(o_ptr)) return FALSE;
6147 if (!object_is_known(j_ptr)) return TRUE;
6149 /* Fixed artifacts, random artifacts and ego items */
6150 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6151 else if (o_ptr->art_name) o_type = 2;
6152 else if (object_is_ego(o_ptr)) o_type = 1;
6155 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6156 else if (j_ptr->art_name) j_type = 2;
6157 else if (object_is_ego(j_ptr)) j_type = 1;
6160 if (o_type < j_type) return TRUE;
6161 if (o_type > j_type) return FALSE;
6163 switch (o_ptr->tval)
6169 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6170 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6176 /* Objects sort by increasing hit/damage bonuses */
6177 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6178 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6181 /* Hack: otherwise identical rods sort by
6182 increasing recharge time --dsb */
6184 if (o_ptr->pval < j_ptr->pval) return TRUE;
6185 if (o_ptr->pval > j_ptr->pval) return FALSE;
6189 /* Objects sort by decreasing value */
6190 return o_value > object_value(j_ptr);
6195 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6196 * Add an item to the players inventory, and return the slot used.
6197 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6198 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6200 * If the new item can combine with an existing item in the inventory,\n
6201 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6202 * the item will be placed into the "proper" location in the inventory.\n
6204 * This function can be used to "over-fill" the player's pack, but only\n
6205 * once, and such an action must trigger the "overflow" code immediately.\n
6206 * Note that when the pack is being "over-filled", the new item must be\n
6207 * placed into the "overflow" slot, and the "overflow" must take place\n
6208 * before the pack is reordered, but (optionally) after the pack is\n
6209 * combined. This may be tricky. See "dungeon.c" for info.\n
6211 * Note that this code must remove any location/stack information\n
6212 * from the object once it is placed into the inventory.\n
6214 s16b inven_carry(object_type *o_ptr)
6222 /* Check for combining */
6223 for (j = 0; j < INVEN_PACK; j++)
6225 j_ptr = &inventory[j];
6227 /* Skip non-objects */
6228 if (!j_ptr->k_idx) continue;
6230 /* Hack -- track last item */
6233 /* Check if the two items can be combined */
6234 if (object_similar(j_ptr, o_ptr))
6236 /* Combine the items */
6237 object_absorb(j_ptr, o_ptr);
6239 /* Increase the weight */
6240 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6242 /* Recalculate bonuses */
6243 p_ptr->update |= (PU_BONUS);
6246 p_ptr->window |= (PW_INVEN);
6255 if (inven_cnt > INVEN_PACK) return (-1);
6257 /* Find an empty slot */
6258 for (j = 0; j <= INVEN_PACK; j++)
6260 j_ptr = &inventory[j];
6262 /* Use it if found */
6263 if (!j_ptr->k_idx) break;
6270 /* Reorder the pack */
6273 /* Get the "value" of the item */
6274 s32b o_value = object_value(o_ptr);
6276 /* Scan every occupied slot */
6277 for (j = 0; j < INVEN_PACK; j++)
6279 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6286 for (k = n; k >= i; k--)
6288 /* Hack -- Slide the item */
6289 object_copy(&inventory[k+1], &inventory[k]);
6292 /* Wipe the empty slot */
6293 object_wipe(&inventory[i]);
6298 object_copy(&inventory[i], o_ptr);
6300 /* Access new object */
6301 j_ptr = &inventory[i];
6304 j_ptr->next_o_idx = 0;
6306 /* Forget monster */
6307 j_ptr->held_m_idx = 0;
6309 /* Forget location */
6310 j_ptr->iy = j_ptr->ix = 0;
6312 /* Player touches it, and no longer marked */
6313 j_ptr->marked = OM_TOUCHED;
6315 /* Increase the weight */
6316 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6318 /* Count the items */
6321 /* Recalculate bonuses */
6322 p_ptr->update |= (PU_BONUS);
6324 /* Combine and Reorder pack */
6325 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6328 p_ptr->window |= (PW_INVEN);
6330 /* Return the slot */
6336 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6337 * Take off (some of) a non-cursed equipment item
6338 * @param item オブジェクトを外したい所持テーブルのID
6340 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6342 * Note that only one item at a time can be wielded per slot.\n
6343 * Note that taking off an item when "full" may cause that item\n
6344 * to fall to the ground.\n
6345 * Return the inventory slot into which the item is placed.\n
6347 s16b inven_takeoff(int item, int amt)
6358 char o_name[MAX_NLEN];
6361 /* Get the item to take off */
6362 o_ptr = &inventory[item];
6365 if (amt <= 0) return (-1);
6368 if (amt > o_ptr->number) amt = o_ptr->number;
6370 /* Get local object */
6373 /* Obtain a local object */
6374 object_copy(q_ptr, o_ptr);
6376 /* Modify quantity */
6377 q_ptr->number = amt;
6379 /* Describe the object */
6380 object_desc(o_name, q_ptr, 0);
6382 /* Took off weapon */
6383 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6384 object_is_melee_weapon(o_ptr))
6386 act = _("を装備からはずした", "You were wielding");
6390 else if (item == INVEN_BOW)
6392 act = _("を装備からはずした", "You were holding");
6395 /* Took off light */
6396 else if (item == INVEN_LITE)
6398 act = _("を光源からはずした", "You were holding");
6401 /* Took off something */
6404 act = _("を装備からはずした", "You were wearing");
6407 /* Modify, Optimize */
6408 inven_item_increase(item, -amt);
6409 inven_item_optimize(item);
6411 /* Carry the object */
6412 slot = inven_carry(q_ptr);
6416 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6418 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6428 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6429 * Drop (some of) a non-cursed inventory/equipment item
6430 * @param item 所持テーブルのID
6431 * @param amt 落としたい個数
6434 * The object will be dropped "near" the current location
6436 void inven_drop(int item, int amt)
6443 char o_name[MAX_NLEN];
6446 /* Access original object */
6447 o_ptr = &inventory[item];
6450 if (amt <= 0) return;
6453 if (amt > o_ptr->number) amt = o_ptr->number;
6456 /* Take off equipment */
6457 if (item >= INVEN_RARM)
6459 /* Take off first */
6460 item = inven_takeoff(item, amt);
6462 /* Access original object */
6463 o_ptr = &inventory[item];
6467 /* Get local object */
6470 /* Obtain local object */
6471 object_copy(q_ptr, o_ptr);
6473 /* Distribute charges of wands or rods */
6474 distribute_charges(o_ptr, q_ptr, amt);
6476 /* Modify quantity */
6477 q_ptr->number = amt;
6479 /* Describe local object */
6480 object_desc(o_name, q_ptr, 0);
6483 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6485 /* Drop it near the player */
6486 (void)drop_near(q_ptr, 0, py, px);
6488 /* Modify, Describe, Optimize */
6489 inven_item_increase(item, -amt);
6490 inven_item_describe(item);
6491 inven_item_optimize(item);
6496 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6497 * Combine items in the pack
6500 * Note special handling of the "overflow" slot
6502 void combine_pack(void)
6507 bool flag = FALSE, combined;
6513 /* Combine the pack (backwards) */
6514 for (i = INVEN_PACK; i > 0; i--)
6517 o_ptr = &inventory[i];
6519 /* Skip empty items */
6520 if (!o_ptr->k_idx) continue;
6522 /* Scan the items above that item */
6523 for (j = 0; j < i; j++)
6528 j_ptr = &inventory[j];
6530 /* Skip empty items */
6531 if (!j_ptr->k_idx) continue;
6534 * Get maximum number of the stack if these
6535 * are similar, get zero otherwise.
6537 max_num = object_similar_part(j_ptr, o_ptr);
6539 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6540 if (max_num && j_ptr->number < max_num)
6542 if (o_ptr->number + j_ptr->number <= max_num)
6547 /* Add together the item counts */
6548 object_absorb(j_ptr, o_ptr);
6550 /* One object is gone */
6553 /* Slide everything down */
6554 for (k = i; k < INVEN_PACK; k++)
6556 /* Structure copy */
6557 inventory[k] = inventory[k+1];
6560 /* Erase the "final" slot */
6561 object_wipe(&inventory[k]);
6565 int old_num = o_ptr->number;
6566 int remain = j_ptr->number + o_ptr->number - max_num;
6568 o_ptr->number -= remain;
6570 /* Add together the item counts */
6571 object_absorb(j_ptr, o_ptr);
6573 o_ptr->number = remain;
6575 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6576 if (o_ptr->tval == TV_ROD)
6578 o_ptr->pval = o_ptr->pval * remain / old_num;
6579 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6582 /* Hack -- if wands are stacking, combine the charges. -LM- */
6583 if (o_ptr->tval == TV_WAND)
6585 o_ptr->pval = o_ptr->pval * remain / old_num;
6590 p_ptr->window |= (PW_INVEN);
6604 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6608 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6609 * Reorder items in the pack
6612 * Note special handling of the "overflow" slot
6614 void reorder_pack(void)
6624 /* Re-order the pack (forwards) */
6625 for (i = 0; i < INVEN_PACK; i++)
6627 /* Mega-Hack -- allow "proper" over-flow */
6628 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6631 o_ptr = &inventory[i];
6633 /* Skip empty slots */
6634 if (!o_ptr->k_idx) continue;
6636 /* Get the "value" of the item */
6637 o_value = object_value(o_ptr);
6639 /* Scan every occupied slot */
6640 for (j = 0; j < INVEN_PACK; j++)
6642 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6645 /* Never move down */
6646 if (j >= i) continue;
6651 /* Get local object */
6654 /* Save a copy of the moving item */
6655 object_copy(q_ptr, &inventory[i]);
6657 /* Slide the objects */
6658 for (k = i; k > j; k--)
6660 /* Slide the item */
6661 object_copy(&inventory[k], &inventory[k-1]);
6664 /* Insert the moving item */
6665 object_copy(&inventory[j], q_ptr);
6668 p_ptr->window |= (PW_INVEN);
6672 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6676 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6677 * Hack -- display an object kind in the current window
6678 * @param k_idx ベースアイテムの参照ID
6681 * Include list of usable spells for readible books
6683 void display_koff(int k_idx)
6692 char o_name[MAX_NLEN];
6695 /* Erase the window */
6696 for (y = 0; y < Term->hgt; y++)
6698 /* Erase the line */
6699 Term_erase(0, y, 255);
6705 /* Get local object */
6708 /* Prepare the object */
6709 object_prep(q_ptr, k_idx);
6712 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6714 /* Mention the object name */
6715 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6717 /* Access the item's sval */
6719 use_realm = tval2realm(q_ptr->tval);
6721 /* Warriors are illiterate */
6722 if (p_ptr->realm1 || p_ptr->realm2)
6724 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6728 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6729 if (!is_magic(use_realm)) return;
6730 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6733 /* Display spells in readible books */
6739 /* Extract spells */
6740 for (spell = 0; spell < 32; spell++)
6742 /* Check for this spell */
6743 if (fake_spell_flags[sval] & (1L << spell))
6745 /* Collect this spell */
6746 spells[num++] = spell;
6751 print_spells(0, spells, num, 2, 0, use_realm);
6756 * @brief 警告を放つアイテムを選択する /
6757 * Choose one of items that have warning flag
6758 * Calculate spell damages
6761 object_type *choose_warning_item(void)
6764 int choices[INVEN_TOTAL - INVEN_RARM];
6767 /* Paranoia -- Player has no warning ability */
6768 if (!p_ptr->warning) return NULL;
6770 /* Search Inventory */
6771 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6773 u32b flgs[TR_FLAG_SIZE];
6774 object_type *o_ptr = &inventory[i];
6776 object_flags(o_ptr, flgs);
6777 if (have_flag(flgs, TR_WARNING))
6779 choices[number] = i;
6784 /* Choice one of them */
6785 return number ? &inventory[choices[randint0(number)]] : NULL;
6789 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6790 * Calculate spell damages
6791 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6792 * @param typ 効果属性のID
6794 * @param max 算出した最大ダメージを返すポインタ
6797 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int *max)
6799 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6800 int rlev = r_ptr->level;
6801 bool ignore_wraith_form = FALSE;
6803 /* Vulnerability, resistance and immunity */
6807 if (p_ptr->immune_elec)
6810 ignore_wraith_form = TRUE;
6814 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6815 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6816 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6817 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6818 if (IS_OPPOSE_ELEC())
6819 dam = (dam + 2) / 3;
6824 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6825 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6829 if (p_ptr->immune_acid)
6832 ignore_wraith_form = TRUE;
6836 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6837 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6838 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6839 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6845 if (p_ptr->immune_cold)
6848 ignore_wraith_form = TRUE;
6852 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6853 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6854 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6855 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6860 if (p_ptr->immune_fire)
6863 ignore_wraith_form = TRUE;
6867 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6868 if (prace_is_(RACE_ENT)) dam += dam / 3;
6869 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6870 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6871 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6876 ignore_wraith_form = TRUE;
6880 if (!p_ptr->blind &&
6881 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6882 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6885 ignore_wraith_form = TRUE;
6890 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6891 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6892 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6895 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6896 * "dam *= 2;" for later "dam /= 2"
6898 if (p_ptr->wraith_form) dam *= 2;
6902 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6905 ignore_wraith_form = TRUE;
6907 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6911 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6915 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6919 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6923 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6927 if (prace_is_(RACE_SPECTRE))
6930 ignore_wraith_form = TRUE;
6932 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6936 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6940 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6944 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6948 if (p_ptr->levitation) dam = (dam * 2) / 3;
6952 if (p_ptr->resist_shard) dam /= 2;
6956 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6957 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6961 if (p_ptr->mimic_form)
6963 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6966 ignore_wraith_form = TRUE;
6971 switch (p_ptr->prace)
6980 ignore_wraith_form = TRUE;
6987 if (p_ptr->align > 10) dam /= 2;
6988 else if (p_ptr->align < -10) dam *= 2;
6992 if (p_ptr->align > 10) dam *= 2;
6996 case GF_BRAIN_SMASH:
6997 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
7000 ignore_wraith_form = TRUE;
7008 if (100 + rlev / 2 <= p_ptr->skill_sav)
7011 ignore_wraith_form = TRUE;
7016 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
7019 ignore_wraith_form = TRUE;
7024 if (p_ptr->wraith_form && !ignore_wraith_form)
7030 if (dam > *max) *max = dam;
7034 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
7035 * Calculate spell damages
7036 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
7037 * @param spell_flag RF4_SHRIEKなどのスペルフラグ
7038 * @param typ 効果属性のID
7039 * @param m_idx 魔法を行使するモンスターのID
7040 * @param max 算出した最大ダメージを返すポインタ
7043 void spell_damcalc_by_spellnum(int spell_num, int typ, int m_idx, int *max)
7045 monster_type *m_ptr = &m_list[m_idx];
7046 int dam = monspell_damage((spell_num), m_idx, DAM_MAX);
7047 spell_damcalc(m_ptr, typ, dam, max);
7051 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
7052 * Calculate blow damages
7053 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
7054 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
7055 * @return 算出された最大ダメージを返す。
7057 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7059 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7061 bool check_wraith_form = TRUE;
7063 if (blow_ptr->method != RBM_EXPLODE)
7065 int ac = p_ptr->ac + p_ptr->to_a;
7067 switch (blow_ptr->effect)
7071 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7072 dam = MAX(dam, tmp_dam * 2);
7078 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7082 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7084 check_wraith_form = FALSE;
7088 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7090 check_wraith_form = FALSE;
7094 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7096 check_wraith_form = FALSE;
7100 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7102 check_wraith_form = FALSE;
7107 check_wraith_form = FALSE;
7111 if (check_wraith_form && p_ptr->wraith_form)
7119 dam = (dam + 1) / 2;
7120 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7128 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7129 * Examine the grid (xx,yy) and warn the player if there are any danger
7130 * @param xx 危険性を調査するマスのX座標
7131 * @param yy 危険性を調査するマスのY座標
7132 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7134 bool process_warning(int xx, int yy)
7138 char o_name[MAX_NLEN];
7140 #define WARNING_AWARE_RANGE 12
7142 static int old_damage = 0;
7144 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7146 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7149 monster_type *m_ptr;
7150 monster_race *r_ptr;
7152 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7154 c_ptr = &cave[my][mx];
7156 if (!c_ptr->m_idx) continue;
7158 m_ptr = &m_list[c_ptr->m_idx];
7160 if (MON_CSLEEP(m_ptr)) continue;
7161 if (!is_hostile(m_ptr)) continue;
7163 r_ptr = &r_info[m_ptr->r_idx];
7165 /* Monster spells (only powerful ones)*/
7166 if (projectable(my, mx, yy, xx))
7168 u32b f4 = r_ptr->flags4;
7169 u32b f5 = r_ptr->flags5;
7170 u32b f6 = r_ptr->flags6;
7172 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7174 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7175 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7176 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7177 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7178 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7179 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7181 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7182 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7183 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7184 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7185 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7186 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7187 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7188 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7189 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7190 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7191 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7192 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7193 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7194 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7195 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7196 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIA, c_ptr->m_idx, &dam_max0);
7197 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7198 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7199 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7200 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7201 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7202 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7203 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7206 /* Monster melee attacks */
7207 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7209 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7213 for (m = 0; m < 4; m++)
7215 /* Skip non-attacks */
7216 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7218 /* Extract the attack info */
7219 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7220 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7222 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7226 /* Contribution from this monster */
7227 dam_max += dam_max0;
7231 /* Prevent excessive warning */
7232 if (dam_max > old_damage)
7234 old_damage = dam_max * 3 / 2;
7236 if (dam_max > p_ptr->chp / 2)
7238 object_type *o_ptr = choose_warning_item();
7241 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7243 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7244 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7247 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7250 else old_damage = old_damage / 2;
7252 c_ptr = &cave[yy][xx];
7253 if (((!easy_disarm && is_trap(c_ptr->feat))
7254 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7256 object_type *o_ptr = choose_warning_item();
7259 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7261 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7262 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7264 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7271 * @brief エッセンスの付加可能な武器や矢弾かを返す
7272 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7273 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7275 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7277 switch (o_ptr->tval)
7290 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7299 * エッセンス情報の構造体 / A structure for smithing
7302 int add; /* TR flag number or special essence id */
7303 cptr add_name; /* Name of this ability */
7304 int type; /* Menu number */
7305 int essence; /* Index for carrying essences */
7306 int value; /* Needed value to add this ability */
7311 * エッセンス情報テーブル Smithing type data for Weapon smith
7314 static essence_type essence_info[] =
7316 {TR_STR, "腕力", 4, TR_STR, 20},
7317 {TR_INT, "知能", 4, TR_INT, 20},
7318 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7319 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7320 {TR_CON, "耐久力", 4, TR_CON, 20},
7321 {TR_CHR, "魅力", 4, TR_CHR, 20},
7322 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7323 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7324 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7325 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7326 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7327 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7328 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7329 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7330 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7331 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7332 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7333 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7334 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7335 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7336 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7337 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7338 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7339 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7340 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7341 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7342 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7343 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7344 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7345 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7346 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7347 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7348 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7349 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7350 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7351 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7352 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7353 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7354 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7355 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7356 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7357 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7358 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7359 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7360 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7361 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7362 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7363 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7364 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7365 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7366 {TR_SH_FIRE, "", 0, -2, 0},
7367 {TR_SH_ELEC, "", 0, -2, 0},
7368 {TR_SH_COLD, "", 0, -2, 0},
7369 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7370 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7371 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7372 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7373 {TR_LITE_2, "", 0, -2, 0},
7374 {TR_LITE_3, "", 0, -2, 0},
7375 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7376 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7377 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7378 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7379 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7381 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7382 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7383 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7384 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7385 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7386 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7387 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7388 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7389 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7390 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7391 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7392 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7393 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7394 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7395 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7396 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7397 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7398 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7400 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7401 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7402 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7403 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7404 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7405 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7406 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7407 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7409 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7410 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7411 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7412 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7413 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7414 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7415 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7416 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7417 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7418 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7419 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7420 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7422 {-1, NULL, 0, -1, 0}
7425 static essence_type essence_info[] =
7427 {TR_STR, "strength", 4, TR_STR, 20},
7428 {TR_INT, "intelligence", 4, TR_INT, 20},
7429 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7430 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7431 {TR_CON, "constitution", 4, TR_CON, 20},
7432 {TR_CHR, "charisma", 4, TR_CHR, 20},
7433 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7434 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7435 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7436 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7437 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7438 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7439 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7440 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7441 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7442 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7443 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7444 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7445 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7446 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7447 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7448 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7449 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7450 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7451 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7452 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7453 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7454 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7455 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7456 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7457 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7458 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7459 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7460 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7461 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7462 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7463 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7464 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7465 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7466 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7467 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7468 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7469 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7470 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7471 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7472 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7473 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7474 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7475 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7476 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7477 {TR_SH_FIRE, "", 0, -2, 0},
7478 {TR_SH_ELEC, "", 0, -2, 0},
7479 {TR_SH_COLD, "", 0, -2, 0},
7480 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7481 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7482 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7483 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7484 {TR_LITE_2, "", 0, -2, 0},
7485 {TR_LITE_3, "", 0, -2, 0},
7486 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7487 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7488 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7489 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7490 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7492 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7493 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7494 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7495 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7496 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7497 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7498 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7499 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7500 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7501 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7502 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7503 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7504 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7505 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7506 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7507 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7508 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7509 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7511 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7512 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7513 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7514 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7515 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7516 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7517 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7518 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7520 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7521 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7522 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7523 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7524 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7525 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7526 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7527 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7528 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7529 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7530 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7531 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7533 {-1, NULL, 0, -1, 0}
7539 * エッセンス名テーブル / Essense names for Weapon smith
7542 cptr essence_name[] =
7645 cptr essence_name[] =
7748 * @brief 所持しているエッセンス一覧を表示する
7751 static void display_essence(void)
7756 for (i = 1; i < 22; i++)
7760 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7761 "Essence Num Essence Num Essence Num "), 1, 8);
7762 for (i = 0; essence_name[i]; i++)
7764 if (!essence_name[i][0]) continue;
7765 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7768 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7778 static void drain_essence(void)
7780 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7783 bool observe = FALSE;
7784 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7785 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7788 byte iy, ix, marked, number;
7789 s16b next_o_idx, weight;
7791 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7794 item_tester_hook = object_is_weapon_armour_ammo;
7795 item_tester_no_ryoute = TRUE;
7798 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7799 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7801 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7803 /* Get the item (in the pack) */
7806 o_ptr = &inventory[item];
7809 /* Get the item (on the floor) */
7812 o_ptr = &o_list[0 - item];
7815 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7817 char o_name[MAX_NLEN];
7818 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7819 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7824 object_flags(o_ptr, old_flgs);
7825 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7826 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7827 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7828 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7829 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7830 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7831 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7832 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7833 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7835 old_to_a = o_ptr->to_a;
7837 old_to_h = o_ptr->to_h;
7838 old_to_d = o_ptr->to_d;
7841 old_pval = o_ptr->pval;
7842 old_name2 = o_ptr->name2;
7843 old_timeout = o_ptr->timeout;
7844 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7845 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7846 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7847 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7848 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7849 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7850 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7851 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7852 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7853 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7854 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7855 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7856 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7857 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7858 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7859 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7860 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7861 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7862 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7866 next_o_idx = o_ptr->next_o_idx;
7867 marked = o_ptr->marked;
7868 weight = o_ptr->weight;
7869 number = o_ptr->number;
7871 object_prep(o_ptr, o_ptr->k_idx);
7875 o_ptr->next_o_idx=next_o_idx;
7876 o_ptr->marked=marked;
7877 o_ptr->number = number;
7878 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7879 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7880 o_ptr->ident |= (IDENT_MENTAL);
7881 object_aware(o_ptr);
7882 object_known(o_ptr);
7884 object_flags(o_ptr, new_flgs);
7886 for (i = 0; essence_info[i].add_name; i++)
7888 essence_type *es_ptr = &essence_info[i];
7891 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7892 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7894 if (es_ptr->add < TR_FLAG_MAX &&
7895 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7896 have_flag(old_flgs, es_ptr->add))
7900 drain_value[es_ptr->essence] += 10 * pval;
7902 else if (es_ptr->essence != -2)
7904 drain_value[es_ptr->essence] += 10;
7906 else if (es_ptr->add == TR_SH_FIRE)
7908 drain_value[TR_BRAND_FIRE] += 10;
7909 drain_value[TR_RES_FIRE] += 10;
7911 else if (es_ptr->add == TR_SH_ELEC)
7913 drain_value[TR_BRAND_ELEC] += 10;
7914 drain_value[TR_RES_ELEC] += 10;
7916 else if (es_ptr->add == TR_SH_COLD)
7918 drain_value[TR_BRAND_COLD] += 10;
7919 drain_value[TR_RES_COLD] += 10;
7921 else if (es_ptr->add == TR_LITE_2)
7923 drain_value[TR_LITE_1] += 20;
7925 else if (es_ptr->add == TR_LITE_3)
7927 drain_value[TR_LITE_1] += 30;
7932 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7934 drain_value[TR_INT] += 5;
7935 drain_value[TR_WIS] += 5;
7937 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7939 drain_value[TR_BRAND_POIS] += 5;
7940 drain_value[TR_BRAND_ACID] += 5;
7941 drain_value[TR_BRAND_ELEC] += 5;
7942 drain_value[TR_BRAND_FIRE] += 5;
7943 drain_value[TR_BRAND_COLD] += 5;
7945 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7947 drain_value[TR_INT] += 10;
7949 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7951 drain_value[TR_STR] += 10;
7953 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7955 drain_value[TR_DEX] += 10;
7957 if (old_name2 == EGO_2WEAPON)
7959 drain_value[TR_DEX] += 20;
7961 if (object_is_weapon_ammo(o_ptr))
7963 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7965 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7967 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7968 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7969 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7970 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7972 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7974 drain_value[i] *= number;
7975 drain_value[i] = drain_value[i] * dec / 4;
7976 drain_value[i] = MAX(drain_value[i], 0);
7977 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7985 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7989 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7991 for (i = 0; essence_name[i]; i++)
7993 if (!essence_name[i][0]) continue;
7994 if (!drain_value[i]) continue;
7996 p_ptr->magic_num1[i] += drain_value[i];
7997 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7999 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
8003 /* Apply autodestroy/inscription to the drained item */
8004 autopick_alter_item(item, TRUE);
8006 /* Combine the pack */
8007 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8010 p_ptr->window |= (PW_INVEN);
8014 * @brief 付加するエッセンスの大別を選択する
8015 * @return 選んだエッセンスの大別ID
8017 static int choose_essence(void)
8021 int menu_line = (use_menu ? 1 : 0);
8024 cptr menu_name[] = {
8034 cptr menu_name[] = {
8044 const int mode_max = 7;
8047 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
8050 #endif /* ALLOW_REPEAT */
8059 for (i = 0; i < mode_max; i++)
8061 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8062 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8064 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8065 prt("Choose from menu.", 0, 0);
8084 menu_line += mode_max - 1;
8093 if (menu_line > mode_max) menu_line -= mode_max;
8104 for (i = 0; i < mode_max; i++)
8105 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8107 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8113 if (isupper(choice)) choice = tolower(choice);
8115 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8116 mode = (int)choice - 'a' + 1;
8123 #endif /* ALLOW_REPEAT */
8128 * @brief エッセンスを実際に付加する
8129 * @param mode エッセンスの大別ID
8132 static void add_essence(int mode)
8134 int item, max_num = 0;
8143 char o_name[MAX_NLEN];
8145 essence_type *es_ptr;
8147 int menu_line = (use_menu ? 1 : 0);
8149 for (i = 0; essence_info[i].add_name; i++)
8151 es_ptr = &essence_info[i];
8153 if (es_ptr->type != mode) continue;
8158 if (!repeat_pull(&i) || i<0 || i>=max_num)
8160 #endif /* ALLOW_REPEAT */
8163 /* Nothing chosen yet */
8169 /* Build a prompt */
8170 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8171 if (use_menu) screen_save();
8173 /* Get a spell from the user */
8175 choice = (always_show_list || use_menu) ? ESCAPE:1;
8179 if( choice==ESCAPE ) choice = ' ';
8180 else if( !get_com(out_val, &choice, FALSE) )break;
8182 if (use_menu && choice != ' ')
8196 menu_line += (max_num-1);
8219 menu_line = max_num;
8233 if (menu_line > max_num) menu_line -= max_num;
8235 /* Request redraw */
8236 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8239 if (!redraw || use_menu)
8243 char dummy[80], dummy2[80];
8251 /* Save the screen */
8252 if (!use_menu) screen_save();
8254 for (y = 1; y < 24; y++)
8257 /* Print header(s) */
8259 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8262 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8265 for (ctr = 0; ctr < max_num; ctr++)
8267 es_ptr = &essence_info[num[ctr]];
8271 if (ctr == (menu_line-1))
8272 strcpy(dummy, _("》 ", "> "));
8273 else strcpy(dummy, " ");
8276 /* letter/number for power selection */
8279 sprintf(dummy, "%c) ",I2A(ctr));
8282 strcat(dummy, es_ptr->add_name);
8287 if (es_ptr->essence != -1)
8289 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8290 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8296 case ESSENCE_SH_FIRE:
8297 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8298 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8299 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8301 case ESSENCE_SH_ELEC:
8302 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8303 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8304 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8306 case ESSENCE_SH_COLD:
8307 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8308 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8309 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8311 case ESSENCE_RESISTANCE:
8312 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8313 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8314 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8315 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8316 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8318 case ESSENCE_SUSTAIN:
8319 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8320 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8321 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8322 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8323 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8328 if (!able[ctr]) col = TERM_RED;
8330 if (es_ptr->essence != -1)
8332 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8336 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8339 c_prt(col, dummy2, ctr+2, x);
8349 /* Restore the screen */
8360 ask = (isupper(choice));
8363 if (ask) choice = tolower(choice);
8365 /* Extract request */
8366 i = (islower(choice) ? A2I(choice) : -1);
8369 /* Totally Illegal */
8370 if ((i < 0) || (i >= max_num) || !able[i])
8382 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8384 /* Belay that order */
8385 if (!get_check(tmp_val)) continue;
8392 /* Restore the screen */
8393 if (redraw) screen_load();
8400 #endif /* ALLOW_REPEAT */
8402 es_ptr = &essence_info[num[i]];
8404 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8405 item_tester_tval = TV_GLOVES;
8406 else if (mode == 1 || mode == 5)
8407 item_tester_hook = item_tester_hook_melee_ammo;
8408 else if (es_ptr->add == ESSENCE_ATTACK)
8409 item_tester_hook = object_allow_enchant_weapon;
8410 else if (es_ptr->add == ESSENCE_AC)
8411 item_tester_hook = object_is_armour;
8413 item_tester_hook = object_is_weapon_armour_ammo;
8414 item_tester_no_ryoute = TRUE;
8417 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8418 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8420 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8422 /* Get the item (in the pack) */
8425 o_ptr = &inventory[item];
8428 /* Get the item (on the floor) */
8431 o_ptr = &o_list[0 - item];
8434 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8436 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8440 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8442 use_essence = es_ptr->value;
8443 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8444 if (o_ptr->number > 1)
8446 use_essence *= o_ptr->number;
8447 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8450 if (es_ptr->essence != -1)
8452 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8454 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8457 if (is_pval_flag(es_ptr->add))
8459 if (o_ptr->pval < 0)
8461 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8464 else if (es_ptr->add == TR_BLOWS)
8466 if (o_ptr->pval > 1)
8468 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8472 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8474 else if (o_ptr->pval > 0)
8476 use_essence *= o_ptr->pval;
8477 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8484 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8486 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8487 strcpy(tmp_val, "1");
8489 if (!get_string(tmp, tmp_val, 1)) return;
8490 pval = atoi(tmp_val);
8491 if (pval > limit) pval = limit;
8492 else if (pval < 1) pval = 1;
8493 o_ptr->pval += pval;
8494 use_essence *= pval;
8495 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8498 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8500 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8504 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8508 int get_to_h, get_to_d;
8510 strcpy(tmp_val, "1");
8511 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8512 val = atoi(tmp_val);
8513 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8514 else if (val < 1) val = 1;
8516 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8517 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8519 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8522 get_to_h = ((val+1)/2+randint0(val/2+1));
8523 get_to_d = ((val+1)/2+randint0(val/2+1));
8524 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8525 o_ptr->to_h += get_to_h;
8526 o_ptr->to_d += get_to_d;
8528 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8529 if (es_ptr->add == ESSENCE_ATTACK)
8531 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8533 msg_print(_("改良に失敗した。", "You failed to enchant."));
8539 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8540 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8543 else if (es_ptr->add == ESSENCE_AC)
8545 if (o_ptr->to_a >= p_ptr->lev/5+5)
8547 msg_print(_("改良に失敗した。", "You failed to enchant."));
8553 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8558 o_ptr->xtra3 = es_ptr->add + 1;
8563 bool success = TRUE;
8567 case ESSENCE_SH_FIRE:
8568 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8573 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8574 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8576 case ESSENCE_SH_ELEC:
8577 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8582 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8583 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8585 case ESSENCE_SH_COLD:
8586 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8591 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8592 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8594 case ESSENCE_RESISTANCE:
8595 case ESSENCE_SUSTAIN:
8596 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))
8601 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8602 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8603 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8604 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8609 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8612 if (es_ptr->add == ESSENCE_SUSTAIN)
8614 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8615 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8616 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8617 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8621 o_ptr->xtra3 = es_ptr->add + 1;
8628 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8630 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8633 /* Combine the pack */
8634 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8637 p_ptr->window |= (PW_INVEN);
8644 static void erase_essence(void)
8649 char o_name[MAX_NLEN];
8650 u32b flgs[TR_FLAG_SIZE];
8652 item_tester_hook = object_is_smith;
8655 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8656 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8658 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8660 /* Get the item (in the pack) */
8663 o_ptr = &inventory[item];
8666 /* Get the item (on the floor) */
8669 o_ptr = &o_list[0 - item];
8672 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8673 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8677 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8679 o_ptr->to_h -= (o_ptr->xtra4>>8);
8680 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8682 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8683 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8686 object_flags(o_ptr, flgs);
8687 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8688 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8690 /* Combine the pack */
8691 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8694 p_ptr->window |= (PW_INVEN);
8698 * @brief 鍛冶コマンドのメインルーチン
8699 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8702 void do_cmd_kaji(bool only_browse)
8707 int menu_line = (use_menu ? 1 : 0);
8711 if (p_ptr->confused)
8713 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8718 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8723 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8729 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8731 #endif /* ALLOW_REPEAT */
8733 if (only_browse) screen_save();
8735 if (!only_browse) screen_save();
8741 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8742 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8743 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8744 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8745 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8746 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8748 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8749 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8750 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8751 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8752 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8753 prt(format("Choose command from menu."), 0, 0);
8780 if (menu_line > 5) menu_line -= 5;
8789 prt(" a) エッセンス一覧", 2, 14);
8790 prt(" b) エッセンス抽出", 3, 14);
8791 prt(" c) エッセンス消去", 4, 14);
8792 prt(" d) エッセンス付加", 5, 14);
8793 prt(" e) 武器/防具強化", 6, 14);
8794 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8796 prt(" a) List essences", 2, 14);
8797 prt(" b) Extract essence", 3, 14);
8798 prt(" c) Remove essence", 4, 14);
8799 prt(" d) Add essence", 5, 14);
8800 prt(" e) Enchant weapon/armor", 6, 14);
8801 if (!get_com("Command :", &choice, TRUE))
8838 /* Clear lines, position cursor (really should use strlen here) */
8839 Term_erase(14, 21, 255);
8840 Term_erase(14, 20, 255);
8841 Term_erase(14, 19, 255);
8842 Term_erase(14, 18, 255);
8843 Term_erase(14, 17, 255);
8844 Term_erase(14, 16, 255);
8846 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8847 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8849 prt(&temp[j], line, 15);
8854 if (!only_browse) screen_load();
8855 } while (only_browse);
8859 #endif /* ALLOW_REPEAT */
8863 case 1: display_essence();break;
8864 case 2: drain_essence();break;
8865 case 3: erase_essence();break;
8867 mode = choose_essence();
8872 case 5: add_essence(10);break;
8878 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8879 * Torches have special abilities when they are flaming.
8880 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8881 * @param flgs 特別に追加するフラグを返す参照ポインタ
8884 void torch_flags(object_type *o_ptr, u32b *flgs)
8886 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8888 if (o_ptr->xtra4 > 0)
8890 add_flag(flgs, TR_BRAND_FIRE);
8891 add_flag(flgs, TR_KILL_UNDEAD);
8892 add_flag(flgs, TR_THROW);
8898 * @brief 投擲時たいまつにダイスを与える。
8899 * Torches have special abilities when they are flaming.
8900 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8901 * @param dd 特別なダイス数を返す参照ポインタ
8902 * @param ds 特別なダイス面数を返す参照ポインタ
8905 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8907 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8909 if (o_ptr->xtra4 > 0)
8918 * @brief 投擲時命中したたいまつの寿命を縮める。
8919 * Torches have special abilities when they are flaming.
8920 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8923 void torch_lost_fuel(object_type *o_ptr)
8925 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8927 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8928 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;