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 * @note アイテム名取得後アイテムの価値に応じたデバッグメッセージを出力する。
2069 * Get Describe and view, Artifact, Random Artifact, Ego-item, and Normal item.
2071 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
2073 if (object_is_fixed_artifact(o_ptr))
2075 msg_format(_("伝説のアイテム (%s)", "Artifact (%s)"), o_name);
2077 else if (o_ptr->art_name)
2079 msg_print(_("ランダム・アーティファクト", "Random artifact"));
2081 else if (object_is_ego(o_ptr))
2083 msg_format(_("名のあるアイテム (%s)", "Ego-item (%s)"), o_name);
2087 msg_format(_("アイテム (%s)", "Object (%s)"), o_name);
2092 * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2093 * Mega-Hack -- Attempt to create one of the "Special Objects"
2094 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2095 * @return 生成に成功したらTRUEを返す。
2097 * We are only called from "make_object()", and we assume that\n
2098 * "apply_magic()" is called immediately after we return.\n
2100 * Note -- see "make_artifact()" and "apply_magic()"\n
2102 static bool make_artifact_special(object_type *o_ptr)
2107 /*! @note 地上ではキャンセルする / No artifacts in the town */
2108 if (!dun_level) return (FALSE);
2110 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2111 if (get_obj_num_hook) return (FALSE);
2113 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2114 for (i = 0; i < max_a_idx; i++)
2116 artifact_type *a_ptr = &a_info[i];
2118 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2119 if (!a_ptr->name) continue;
2121 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2122 if (a_ptr->cur_num) continue;
2123 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2124 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2126 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2127 * XXX XXX Enforce minimum "depth" (loosely) */
2128 if (a_ptr->level > object_level)
2130 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2131 int d = (a_ptr->level - object_level) * 2;
2132 if (!one_in_(d)) continue;
2135 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2136 if (!one_in_(a_ptr->rarity)) continue;
2138 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2139 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2140 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2141 if (k_info[k_idx].level > object_level)
2143 int d = (k_info[k_idx].level - object_level) * 5;
2144 if (!one_in_(d)) continue;
2147 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2148 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2149 object_prep(o_ptr, k_idx);
2152 random_artifact_resistance(o_ptr, a_ptr);
2156 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2162 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2163 * Mega-Hack -- Attempt to create one of the "Special Objects"
2164 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2165 * @return 生成に成功したらTRUEを返す。
2167 * Attempt to change an object into an artifact\n
2168 * This routine should only be called by "apply_magic()"\n
2169 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2171 static bool make_artifact(object_type *o_ptr)
2176 /* No artifacts in the town */
2177 if (!dun_level) return (FALSE);
2179 /* Paranoia -- no "plural" artifacts */
2180 if (o_ptr->number != 1) return (FALSE);
2182 /* Check the artifact list (skip the "specials") */
2183 for (i = 0; i < max_a_idx; i++)
2185 artifact_type *a_ptr = &a_info[i];
2187 /* Skip "empty" items */
2188 if (!a_ptr->name) continue;
2190 /* Cannot make an artifact twice */
2191 if (a_ptr->cur_num) continue;
2193 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2195 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2197 /* Must have the correct fields */
2198 if (a_ptr->tval != o_ptr->tval) continue;
2199 if (a_ptr->sval != o_ptr->sval) continue;
2201 /* XXX XXX Enforce minimum "depth" (loosely) */
2202 if (a_ptr->level > dun_level)
2204 /* Acquire the "out-of-depth factor" */
2205 int d = (a_ptr->level - dun_level) * 2;
2207 /* Roll for out-of-depth creation */
2208 if (!one_in_(d)) continue;
2211 /* We must make the "rarity roll" */
2212 if (!one_in_(a_ptr->rarity)) continue;
2214 /* Hack -- mark the item as an artifact */
2217 /* Hack: Some artifacts get random extra powers */
2218 random_artifact_resistance(o_ptr, a_ptr);
2230 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2231 * Choose random ego type
2232 * @param slot 取得したいエゴの装備部位
2233 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2234 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2236 static byte get_random_ego(byte slot, bool good)
2239 ego_item_type *e_ptr;
2243 for (i = 1; i < max_e_idx; i++)
2247 if (e_ptr->slot == slot
2248 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2251 total += (255 / e_ptr->rarity);
2255 value = randint1(total);
2257 for (i = 1; i < max_e_idx; i++)
2261 if (e_ptr->slot == slot
2262 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2265 value -= (255 / e_ptr->rarity);
2266 if (value <= 0L) break;
2274 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2275 * Apply magic to an item known to be a "weapon"
2276 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2277 * @param level 生成基準階
2278 * @param power 生成ランク
2281 * Hack -- note special base damage dice boosting\n
2282 * Hack -- note special processing for weapon/digger\n
2284 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2286 int tohit1 = randint1(5) + m_bonus(5, level);
2287 int todam1 = randint1(5) + m_bonus(5, level);
2289 int tohit2 = m_bonus(10, level);
2290 int todam2 = m_bonus(10, level);
2292 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2294 tohit2 = (tohit2+1)/2;
2295 todam2 = (todam2+1)/2;
2302 o_ptr->to_h += tohit1;
2303 o_ptr->to_d += todam1;
2309 o_ptr->to_h += tohit2;
2310 o_ptr->to_d += todam2;
2318 o_ptr->to_h -= tohit1;
2319 o_ptr->to_d -= todam1;
2324 /* Penalize again */
2325 o_ptr->to_h -= tohit2;
2326 o_ptr->to_d -= todam2;
2329 /* Cursed (if "bad") */
2330 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2333 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2336 switch (o_ptr->tval)
2343 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2344 create_artifact(o_ptr, FALSE);
2346 /* Special Ego-item */
2347 o_ptr->name2 = EGO_DIGGING;
2351 else if (power < -1)
2353 /* Hack -- Horrible digging bonus */
2354 o_ptr->pval = 0 - (5 + randint1(5));
2360 /* Hack -- Reverse digging bonus */
2361 o_ptr->pval = 0 - (o_ptr->pval);
2375 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2377 create_artifact(o_ptr, FALSE);
2382 /* Roll for an ego-item */
2383 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2384 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2386 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2388 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2393 switch (o_ptr->name2)
2396 if (one_in_(4) && (level > 40))
2397 add_flag(o_ptr->art_flags, TR_BLOWS);
2401 add_flag(o_ptr->art_flags, TR_RES_POIS);
2403 add_flag(o_ptr->art_flags, TR_WARNING);
2405 case EGO_KILL_DRAGON:
2407 add_flag(o_ptr->art_flags, TR_RES_POIS);
2411 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2413 case EGO_SLAYING_WEAPON:
2414 if (one_in_(3)) /* double damage */
2422 while (one_in_(o_ptr->dd));
2428 while (one_in_(o_ptr->ds));
2433 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2435 if (o_ptr->tval == TV_SWORD && one_in_(3))
2437 add_flag(o_ptr->art_flags, TR_VORPAL);
2442 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2448 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2450 add_flag(o_ptr->art_flags, TR_DEX);
2452 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2455 o_ptr->pval = m_bonus(5, level) + 1;
2457 case EGO_EARTHQUAKES:
2458 if (one_in_(3) && (level > 60))
2459 add_flag(o_ptr->art_flags, TR_BLOWS);
2461 o_ptr->pval = m_bonus(3, level);
2465 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2469 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2471 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2473 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2474 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2477 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2478 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2479 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2480 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2484 if (!o_ptr->art_name)
2486 /* Hack -- Super-charge the damage dice */
2487 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2489 /* Hack -- Lower the damage dice */
2490 if (o_ptr->dd > 9) o_ptr->dd = 9;
2495 else if (power < -1)
2497 /* Roll for ego-item */
2498 if (randint0(MAX_DEPTH) < level)
2502 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2503 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2509 switch (o_ptr->name2)
2512 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2513 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2515 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2516 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2517 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2518 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2519 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2520 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2534 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2536 create_artifact(o_ptr, FALSE);
2539 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2553 if (power > 2) /* power > 2 is debug only */
2555 create_artifact(o_ptr, FALSE);
2559 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2561 switch (o_ptr->name2)
2563 case EGO_SLAYING_BOLT:
2568 /* Hack -- super-charge the damage dice */
2569 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2571 /* Hack -- restrict the damage dice */
2572 if (o_ptr->dd > 9) o_ptr->dd = 9;
2576 else if (power < -1)
2578 /* Roll for ego-item */
2579 if (randint0(MAX_DEPTH) < level)
2581 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2591 * @brief ドラゴン装備にランダムな耐性を与える
2592 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2595 static void dragon_resist(object_type * o_ptr)
2600 one_dragon_ele_resistance(o_ptr);
2602 one_high_resistance(o_ptr);
2608 * @brief オブジェクトにランダムな強いESPを与える
2609 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2612 static bool add_esp_strong(object_type *o_ptr)
2614 bool nonliv = FALSE;
2616 switch (randint1(3))
2618 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2619 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2620 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2627 * @brief オブジェクトにランダムな弱いESPを与える
2628 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2629 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2632 static void add_esp_weak(object_type *o_ptr, bool extra)
2635 u32b weak_esp_list[] = {
2647 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2648 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2650 /* Add unduplicated weak esp flags randomly */
2651 for (i = 0; i < add_count; ++ i)
2653 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2655 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2656 weak_esp_list[choice] = weak_esp_list[i];
2662 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2663 * Apply magic to an item known to be "armor"
2664 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2665 * @param level 生成基準階
2666 * @param power 生成ランク
2669 * Hack -- note special processing for crown/helm\n
2670 * Hack -- note special processing for robe of permanence\n
2672 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2674 int toac1 = randint1(5) + m_bonus(5, level);
2676 int toac2 = m_bonus(10, level);
2682 o_ptr->to_a += toac1;
2688 o_ptr->to_a += toac2;
2696 o_ptr->to_a -= toac1;
2701 /* Penalize again */
2702 o_ptr->to_a -= toac2;
2705 /* Cursed (if "bad") */
2706 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2711 switch (o_ptr->tval)
2715 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2716 create_artifact(o_ptr, FALSE);
2718 /* Mention the item */
2719 if (cheat_peek) object_mention(o_ptr);
2730 /* Hack -- Try for "Robes of the Magi" */
2731 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2732 (o_ptr->sval == SV_ROBE) &&
2733 (randint0(100) < 15))
2737 o_ptr->name2 = EGO_YOIYAMI;
2738 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2739 o_ptr->sval = SV_YOIYAMI_ROBE;
2745 o_ptr->name2 = EGO_PERMANENCE;
2750 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2752 create_artifact(o_ptr, FALSE);
2758 bool okay_flag = TRUE;
2760 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2762 switch (o_ptr->name2)
2765 if (o_ptr->tval != TV_HARD_ARMOR)
2771 if (o_ptr->tval != TV_SOFT_ARMOR)
2783 switch (o_ptr->name2)
2785 case EGO_RESISTANCE:
2787 add_flag(o_ptr->art_flags, TR_RES_POIS);
2790 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2791 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2795 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2797 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2799 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2800 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2802 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2803 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2804 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2805 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2806 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2807 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2808 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2809 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2812 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2813 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2814 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2815 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2816 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2817 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2830 if (o_ptr->sval == SV_DRAGON_SHIELD)
2832 /* Mention the item */
2833 if (cheat_peek) object_mention(o_ptr);
2834 dragon_resist(o_ptr);
2835 if (!one_in_(3)) break;
2841 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2843 create_artifact(o_ptr, FALSE);
2849 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2850 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2851 && o_ptr->name2 == EGO_S_DWARVEN)
2858 switch (o_ptr->name2)
2861 if (!one_in_(3)) one_high_resistance(o_ptr);
2862 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2864 case EGO_REFLECTION:
2865 if (o_ptr->sval == SV_MIRROR_SHIELD)
2870 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2871 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2880 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2882 /* Mention the item */
2883 if (cheat_peek) object_mention(o_ptr);
2884 dragon_resist(o_ptr);
2885 if (!one_in_(3)) break;
2889 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2891 create_artifact(o_ptr, FALSE);
2894 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2898 else if (power < -1)
2900 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2908 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2910 /* Mention the item */
2911 if (cheat_peek) object_mention(o_ptr);
2912 dragon_resist(o_ptr);
2913 if (!one_in_(3)) break;
2918 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2920 create_artifact(o_ptr, FALSE);
2923 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2925 switch (o_ptr->name2)
2927 case EGO_SLOW_DESCENT:
2930 one_high_resistance(o_ptr);
2936 else if (power < -1)
2938 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2949 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2951 create_artifact(o_ptr, FALSE);
2956 bool ok_flag = TRUE;
2957 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2959 switch (o_ptr->name2)
2962 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2963 else add_esp_weak(o_ptr, FALSE);
2967 case EGO_REGENERATION:
2968 case EGO_LORDLINESS:
2974 if (one_in_(2)) add_esp_strong(o_ptr);
2975 else add_esp_weak(o_ptr, FALSE);
2978 default:/* not existing crown (wisdom,lite, etc...) */
2982 break; /* while (1) */
2988 else if (power < -1)
2992 bool ok_flag = TRUE;
2993 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
2995 switch (o_ptr->name2)
2997 case EGO_ANCIENT_CURSE:
2998 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2999 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3000 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3001 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3002 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3003 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3007 break; /* while (1) */
3016 if (o_ptr->sval == SV_DRAGON_HELM)
3018 /* Mention the item */
3019 if (cheat_peek) object_mention(o_ptr);
3020 dragon_resist(o_ptr);
3021 if (!one_in_(3)) break;
3027 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3029 create_artifact(o_ptr, FALSE);
3034 bool ok_flag = TRUE;
3035 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3037 switch (o_ptr->name2)
3039 case EGO_BRILLIANCE:
3041 case EGO_INFRAVISION:
3042 case EGO_H_PROTECTION:
3047 if (one_in_(2)) add_esp_strong(o_ptr);
3048 else add_esp_weak(o_ptr, FALSE);
3052 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3053 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3056 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3058 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3060 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3061 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3063 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3064 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3065 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3066 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3067 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3068 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3069 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3070 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3072 default:/* not existing helm (Magi, Might, etc...)*/
3076 break; /* while (1) */
3081 else if (power < -1)
3085 bool ok_flag = TRUE;
3086 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3088 switch (o_ptr->name2)
3090 case EGO_ANCIENT_CURSE:
3094 break; /* while (1) */
3105 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3107 create_artifact(o_ptr, FALSE);
3110 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3112 switch (o_ptr->name2)
3121 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3122 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3123 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3124 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3131 else if (power < -1)
3133 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3143 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3144 * Apply magic to an item known to be a "ring" or "amulet"
3145 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3146 * @param level 生成基準階
3147 * @param power 生成ランク
3150 * Hack -- note special "pval boost" code for ring of speed\n
3151 * Hack -- note that some items must be cursed (or blessed)\n
3153 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3155 /* Apply magic (good or bad) according to type */
3156 switch (o_ptr->tval)
3161 switch (o_ptr->sval)
3163 case SV_RING_ATTACKS:
3166 o_ptr->pval = m_bonus(2, level);
3167 if (one_in_(15)) o_ptr->pval++;
3168 if (o_ptr->pval < 1) o_ptr->pval = 1;
3174 o_ptr->ident |= (IDENT_BROKEN);
3177 o_ptr->curse_flags |= TRC_CURSED;
3180 o_ptr->pval = 0 - (o_ptr->pval);
3191 /* Strength, Constitution, Dexterity, Intelligence */
3197 o_ptr->pval = 1 + m_bonus(5, level);
3203 o_ptr->ident |= (IDENT_BROKEN);
3206 o_ptr->curse_flags |= TRC_CURSED;
3209 o_ptr->pval = 0 - (o_ptr->pval);
3215 /* Ring of Speed! */
3218 /* Base speed (1 to 10) */
3219 o_ptr->pval = randint1(5) + m_bonus(5, level);
3221 /* Super-charge the ring */
3222 while (randint0(100) < 50) o_ptr->pval++;
3228 o_ptr->ident |= (IDENT_BROKEN);
3231 o_ptr->curse_flags |= TRC_CURSED;
3234 o_ptr->pval = 0 - (o_ptr->pval);
3239 /* Mention the item */
3240 if (cheat_peek) object_mention(o_ptr);
3245 case SV_RING_LORDLY:
3249 one_lordly_high_resistance(o_ptr);
3253 /* Bonus to armor class */
3254 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3258 case SV_RING_WARNING:
3260 if (one_in_(3)) one_low_esp(o_ptr);
3265 case SV_RING_SEARCHING:
3267 /* Bonus to searching */
3268 o_ptr->pval = 1 + m_bonus(5, level);
3274 o_ptr->ident |= (IDENT_BROKEN);
3277 o_ptr->curse_flags |= TRC_CURSED;
3280 o_ptr->pval = 0 - (o_ptr->pval);
3286 /* Flames, Acid, Ice */
3287 case SV_RING_FLAMES:
3292 /* Bonus to armor class */
3293 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3297 /* Weakness, Stupidity */
3298 case SV_RING_WEAKNESS:
3299 case SV_RING_STUPIDITY:
3302 o_ptr->ident |= (IDENT_BROKEN);
3305 o_ptr->curse_flags |= TRC_CURSED;
3308 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3309 if (power > 0) power = 0 - power;
3314 /* WOE, Stupidity */
3318 o_ptr->ident |= (IDENT_BROKEN);
3321 o_ptr->curse_flags |= TRC_CURSED;
3324 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3325 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3326 if (power > 0) power = 0 - power;
3331 /* Ring of damage */
3332 case SV_RING_DAMAGE:
3334 /* Bonus to damage */
3335 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3341 o_ptr->ident |= (IDENT_BROKEN);
3344 o_ptr->curse_flags |= TRC_CURSED;
3347 o_ptr->to_d = 0 - o_ptr->to_d;
3353 /* Ring of Accuracy */
3354 case SV_RING_ACCURACY:
3357 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3363 o_ptr->ident |= (IDENT_BROKEN);
3366 o_ptr->curse_flags |= TRC_CURSED;
3369 o_ptr->to_h = 0 - o_ptr->to_h;
3375 /* Ring of Protection */
3376 case SV_RING_PROTECTION:
3378 /* Bonus to armor class */
3379 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3385 o_ptr->ident |= (IDENT_BROKEN);
3388 o_ptr->curse_flags |= TRC_CURSED;
3391 o_ptr->to_a = 0 - o_ptr->to_a;
3397 /* Ring of Slaying */
3398 case SV_RING_SLAYING:
3400 /* Bonus to damage and to hit */
3401 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3402 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3408 o_ptr->ident |= (IDENT_BROKEN);
3411 o_ptr->curse_flags |= TRC_CURSED;
3413 /* Reverse bonuses */
3414 o_ptr->to_h = 0 - o_ptr->to_h;
3415 o_ptr->to_d = 0 - o_ptr->to_d;
3421 case SV_RING_MUSCLE:
3423 o_ptr->pval = 1 + m_bonus(3, level);
3424 if (one_in_(4)) o_ptr->pval++;
3430 o_ptr->ident |= (IDENT_BROKEN);
3433 o_ptr->curse_flags |= TRC_CURSED;
3435 /* Reverse bonuses */
3436 o_ptr->pval = 0 - o_ptr->pval;
3441 case SV_RING_AGGRAVATION:
3444 o_ptr->ident |= (IDENT_BROKEN);
3447 o_ptr->curse_flags |= TRC_CURSED;
3449 if (power > 0) power = 0 - power;
3453 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3454 || (power > 2)) /* power > 2 is debug only */
3456 o_ptr->pval = MIN(o_ptr->pval, 4);
3457 /* Randart amulet */
3458 create_artifact(o_ptr, FALSE);
3460 else if ((power == 2) && one_in_(2))
3462 while(!o_ptr->name2)
3464 int tmp = m_bonus(10, level);
3465 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3466 switch(randint1(28))
3469 o_ptr->name2 = EGO_RING_THROW;
3472 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3473 o_ptr->name2 = EGO_RING_REGEN;
3476 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3477 o_ptr->name2 = EGO_RING_LITE;
3480 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3481 o_ptr->name2 = EGO_RING_TELEPORT;
3484 if (o_ptr->to_h) break;
3485 o_ptr->name2 = EGO_RING_TO_H;
3488 if (o_ptr->to_d) break;
3489 o_ptr->name2 = EGO_RING_TO_D;
3492 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3493 o_ptr->name2 = EGO_RING_SLAY;
3496 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3497 o_ptr->name2 = EGO_RING_WIZARD;
3500 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3501 o_ptr->name2 = EGO_RING_HERO;
3504 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3505 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3506 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3507 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3510 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3511 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;
3512 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3513 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3514 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3517 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3518 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;
3519 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3520 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3521 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3524 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3525 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;
3526 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3527 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3530 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3531 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;
3532 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3533 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3535 case 21: case 22: case 23: case 24: case 25: case 26:
3536 switch (o_ptr->sval)
3539 if (!one_in_(3)) break;
3540 o_ptr->name2 = EGO_RING_D_SPEED;
3542 case SV_RING_DAMAGE:
3543 case SV_RING_ACCURACY:
3544 case SV_RING_SLAYING:
3545 if (one_in_(2)) break;
3546 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3549 o_ptr->name2 = EGO_RING_BERSERKER;
3550 o_ptr->to_h -= 2+randint1(4);
3551 o_ptr->to_d += 2+randint1(4);
3554 case SV_RING_PROTECTION:
3555 o_ptr->name2 = EGO_RING_SUPER_AC;
3556 o_ptr->to_a += 7 + m_bonus(5, level);
3558 case SV_RING_RES_FEAR:
3559 o_ptr->name2 = EGO_RING_HERO;
3562 if (one_in_(2)) break;
3563 o_ptr->name2 = EGO_RING_HUNTER;
3565 case SV_RING_SEARCHING:
3566 o_ptr->name2 = EGO_RING_STEALTH;
3568 case SV_RING_TELEPORTATION:
3569 o_ptr->name2 = EGO_RING_TELE_AWAY;
3571 case SV_RING_RES_BLINDNESS:
3573 o_ptr->name2 = EGO_RING_RES_LITE;
3575 o_ptr->name2 = EGO_RING_RES_DARK;
3577 case SV_RING_LORDLY:
3578 if (!one_in_(20)) break;
3579 one_lordly_high_resistance(o_ptr);
3580 one_lordly_high_resistance(o_ptr);
3581 o_ptr->name2 = EGO_RING_TRUE;
3583 case SV_RING_SUSTAIN:
3584 if (!one_in_(4)) break;
3585 o_ptr->name2 = EGO_RING_RES_TIME;
3587 case SV_RING_FLAMES:
3588 if (!one_in_(2)) break;
3589 o_ptr->name2 = EGO_RING_DRAGON_F;
3592 if (!one_in_(2)) break;
3593 o_ptr->name2 = EGO_RING_DRAGON_C;
3595 case SV_RING_WARNING:
3596 if (!one_in_(2)) break;
3597 o_ptr->name2 = EGO_RING_M_DETECT;
3606 o_ptr->curse_flags = 0L;
3608 else if ((power == -2) && one_in_(2))
3610 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3611 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3612 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3613 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3614 o_ptr->art_flags[0] = 0;
3615 o_ptr->art_flags[1] = 0;
3616 while(!o_ptr->name2)
3618 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3622 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3623 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3626 o_ptr->name2 = EGO_RING_NO_MELEE;
3629 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3630 o_ptr->name2 = EGO_RING_AGGRAVATE;
3633 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3634 o_ptr->name2 = EGO_RING_TY_CURSE;
3637 o_ptr->name2 = EGO_RING_ALBINO;
3642 o_ptr->ident |= (IDENT_BROKEN);
3645 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3653 switch (o_ptr->sval)
3655 /* Amulet of wisdom/charisma */
3656 case SV_AMULET_INTELLIGENCE:
3657 case SV_AMULET_WISDOM:
3658 case SV_AMULET_CHARISMA:
3660 o_ptr->pval = 1 + m_bonus(5, level);
3666 o_ptr->ident |= (IDENT_BROKEN);
3669 o_ptr->curse_flags |= (TRC_CURSED);
3671 /* Reverse bonuses */
3672 o_ptr->pval = 0 - o_ptr->pval;
3678 /* Amulet of brilliance */
3679 case SV_AMULET_BRILLIANCE:
3681 o_ptr->pval = 1 + m_bonus(3, level);
3682 if (one_in_(4)) o_ptr->pval++;
3688 o_ptr->ident |= (IDENT_BROKEN);
3691 o_ptr->curse_flags |= (TRC_CURSED);
3693 /* Reverse bonuses */
3694 o_ptr->pval = 0 - o_ptr->pval;
3700 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3704 o_ptr->curse_flags |= (TRC_CURSED);
3709 case SV_AMULET_RESISTANCE:
3711 if (one_in_(5)) one_high_resistance(o_ptr);
3712 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3716 /* Amulet of searching */
3717 case SV_AMULET_SEARCHING:
3719 o_ptr->pval = randint1(2) + m_bonus(4, level);
3725 o_ptr->ident |= (IDENT_BROKEN);
3728 o_ptr->curse_flags |= (TRC_CURSED);
3730 /* Reverse bonuses */
3731 o_ptr->pval = 0 - (o_ptr->pval);
3737 /* Amulet of the Magi -- never cursed */
3738 case SV_AMULET_THE_MAGI:
3740 o_ptr->pval = randint1(5) + m_bonus(5, level);
3741 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3743 /* gain one low ESP */
3744 add_esp_weak(o_ptr, FALSE);
3746 /* Mention the item */
3747 if (cheat_peek) object_mention(o_ptr);
3752 /* Amulet of Doom -- always cursed */
3753 case SV_AMULET_DOOM:
3756 o_ptr->ident |= (IDENT_BROKEN);
3759 o_ptr->curse_flags |= (TRC_CURSED);
3762 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3763 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3764 if (power > 0) power = 0 - power;
3769 case SV_AMULET_MAGIC_MASTERY:
3771 o_ptr->pval = 1 + m_bonus(4, level);
3777 o_ptr->ident |= (IDENT_BROKEN);
3780 o_ptr->curse_flags |= (TRC_CURSED);
3782 /* Reverse bonuses */
3783 o_ptr->pval = 0 - o_ptr->pval;
3789 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3790 || (power > 2)) /* power > 2 is debug only */
3792 o_ptr->pval = MIN(o_ptr->pval, 4);
3793 /* Randart amulet */
3794 create_artifact(o_ptr, FALSE);
3796 else if ((power == 2) && one_in_(2))
3798 while(!o_ptr->name2)
3800 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3801 switch(randint1(21))
3804 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3805 o_ptr->name2 = EGO_AMU_SLOW_D;
3808 if (o_ptr->pval) break;
3809 o_ptr->name2 = EGO_AMU_INFRA;
3812 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3813 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3816 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3817 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3820 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3821 o_ptr->name2 = EGO_AMU_LEVITATION;
3823 case 10: case 11: case 21:
3824 o_ptr->name2 = EGO_AMU_AC;
3827 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3828 if (m_bonus(10, level) > 8)
3829 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3831 o_ptr->name2 = EGO_AMU_RES_FIRE;
3834 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3835 if (m_bonus(10, level) > 8)
3836 o_ptr->name2 = EGO_AMU_RES_COLD_;
3838 o_ptr->name2 = EGO_AMU_RES_COLD;
3841 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3842 if (m_bonus(10, level) > 8)
3843 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3845 o_ptr->name2 = EGO_AMU_RES_ELEC;
3848 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3849 if (m_bonus(10, level) > 8)
3850 o_ptr->name2 = EGO_AMU_RES_ACID_;
3852 o_ptr->name2 = EGO_AMU_RES_ACID;
3854 case 16: case 17: case 18: case 19: case 20:
3855 switch (o_ptr->sval)
3857 case SV_AMULET_TELEPORT:
3858 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3859 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3860 else o_ptr->name2 = EGO_AMU_TELEPORT;
3862 case SV_AMULET_RESIST_ACID:
3863 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3865 case SV_AMULET_SEARCHING:
3866 o_ptr->name2 = EGO_AMU_STEALTH;
3868 case SV_AMULET_BRILLIANCE:
3869 if (!one_in_(3)) break;
3870 o_ptr->name2 = EGO_AMU_IDENT;
3872 case SV_AMULET_CHARISMA:
3873 if (!one_in_(3)) break;
3874 o_ptr->name2 = EGO_AMU_CHARM;
3876 case SV_AMULET_THE_MAGI:
3877 if (one_in_(2)) break;
3878 o_ptr->name2 = EGO_AMU_GREAT;
3880 case SV_AMULET_RESISTANCE:
3881 if (!one_in_(5)) break;
3882 o_ptr->name2 = EGO_AMU_DEFENDER;
3884 case SV_AMULET_TELEPATHY:
3885 if (!one_in_(3)) break;
3886 o_ptr->name2 = EGO_AMU_DETECTION;
3892 o_ptr->curse_flags = 0L;
3894 else if ((power == -2) && one_in_(2))
3896 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3897 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3898 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3899 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3900 o_ptr->art_flags[0] = 0;
3901 o_ptr->art_flags[1] = 0;
3902 while(!o_ptr->name2)
3904 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3908 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3909 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3912 o_ptr->name2 = EGO_AMU_FOOL;
3915 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3916 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3919 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3920 o_ptr->name2 = EGO_AMU_TY_CURSE;
3923 o_ptr->name2 = EGO_AMU_NAIVETY;
3928 o_ptr->ident |= (IDENT_BROKEN);
3931 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3939 * @brief モンスターが人形のベースにできるかを返す
3940 * @param r_idx チェックしたいモンスター種族のID
3941 * @return 人形にできるならTRUEを返す
3943 static bool item_monster_okay(int r_idx)
3945 monster_race *r_ptr = &r_info[r_idx];
3948 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3949 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3950 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3951 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3952 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3953 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3961 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3962 * Apply magic to an item known to be "boring"
3963 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3964 * @param level 生成基準階
3965 * @param power 生成ランク
3968 * Hack -- note the special code for various items
3970 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3972 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3977 /* Apply magic (good or bad) according to type */
3978 switch (o_ptr->tval)
3987 o_ptr->ident |= (IDENT_BROKEN);
3990 o_ptr->curse_flags |= (TRC_CURSED);
3997 o_ptr->xtra4 = o_ptr->pval;
4003 /* Hack -- Torches -- random fuel */
4004 if (o_ptr->sval == SV_LITE_TORCH)
4006 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4010 /* Hack -- Lanterns -- random fuel */
4011 if (o_ptr->sval == SV_LITE_LANTERN)
4013 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4017 if (power > 2) /* power > 2 is debug only */
4019 create_artifact(o_ptr, FALSE);
4021 else if ((power == 2) || ((power == 1) && one_in_(3)))
4023 while (!o_ptr->name2)
4027 bool okay_flag = TRUE;
4029 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4031 switch (o_ptr->name2)
4034 if (o_ptr->sval == SV_LITE_FEANOR)
4042 else if (power == -2)
4044 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4046 switch (o_ptr->name2)
4048 case EGO_LITE_DARKNESS:
4051 if (o_ptr->sval == SV_LITE_TORCH)
4053 add_flag(o_ptr->art_flags, TR_LITE_M1);
4055 else if (o_ptr->sval == SV_LITE_LANTERN)
4057 add_flag(o_ptr->art_flags, TR_LITE_M2);
4059 else if (o_ptr->sval == SV_LITE_FEANOR)
4061 add_flag(o_ptr->art_flags, TR_LITE_M3);
4073 /* The wand or staff gets a number of initial charges equal
4074 * to between 1/2 (+1) and the full object kind's pval. -LM-
4076 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4082 /* Transfer the pval. -LM- */
4083 o_ptr->pval = k_ptr->pval;
4090 object_aware(o_ptr);
4091 object_known(o_ptr);
4100 monster_race *r_ptr;
4102 /* Pick a random non-unique monster race */
4105 i = randint1(max_r_idx - 1);
4107 if (!item_monster_okay(i)) continue;
4108 if (i == MON_TSUCHINOKO) continue;
4112 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4114 /* Ignore dead monsters */
4115 if (!r_ptr->rarity) continue;
4117 /* Ignore uncommon monsters */
4118 if (r_ptr->rarity > 100) continue;
4120 /* Prefer less out-of-depth monsters */
4121 if (randint0(check)) continue;
4128 /* Some figurines are cursed */
4129 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4133 msg_format(_("%sの人形, 深さ +%d%s", "Figurine of %s, depth +%d%s"),
4134 r_name + r_ptr->name, check - 1,
4135 !object_is_cursed(o_ptr) ? "" : " {cursed}");
4148 monster_race *r_ptr;
4150 if (o_ptr->sval == SV_SKELETON)
4152 match = RF9_DROP_SKELETON;
4154 else if (o_ptr->sval == SV_CORPSE)
4156 match = RF9_DROP_CORPSE;
4159 /* Hack -- Remove the monster restriction */
4160 get_mon_num_prep(item_monster_okay, NULL);
4162 /* Pick a random non-unique monster race */
4165 i = get_mon_num(dun_level);
4169 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4171 /* Ignore dead monsters */
4172 if (!r_ptr->rarity) continue;
4174 /* Ignore corpseless monsters */
4175 if (!(r_ptr->flags9 & match)) continue;
4177 /* Prefer less out-of-depth monsters */
4178 if (randint0(check)) continue;
4187 msg_format(_("%sの死体, 深さ +%d", "Corpse of %s, depth +%d"),
4188 r_name + r_ptr->name, check - 1);
4191 object_aware(o_ptr);
4192 object_known(o_ptr);
4200 monster_race *r_ptr;
4202 /* Pick a random monster race */
4205 i = randint1(max_r_idx - 1);
4209 /* Ignore dead monsters */
4210 if (!r_ptr->rarity) continue;
4219 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4221 object_aware(o_ptr);
4222 object_known(o_ptr);
4229 byte obj_level = k_info[o_ptr->k_idx].level;
4231 /* Hack -- skip ruined chests */
4232 if (obj_level <= 0) break;
4234 /* Hack -- pick a "difficulty" */
4235 o_ptr->pval = randint1(obj_level);
4236 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4238 o_ptr->xtra3 = dun_level + 5;
4240 /* Never exceed "difficulty" of 55 to 59 */
4241 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4249 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4250 * Complete the "creation" of an object by applying "magic" to the item
4251 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4253 * @param mode 生成オプション
4256 * This includes not only rolling for random bonuses, but also putting the\n
4257 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4258 * staffs, giving fuel to lites, and placing traps on chests.\n
4260 * In particular, note that "Instant Artifacts", if "created" by an external\n
4261 * routine, must pass through this function to complete the actual creation.\n
4263 * The base "chance" of the item being "good" increases with the "level"\n
4264 * parameter, which is usually derived from the dungeon level, being equal\n
4265 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4266 * the object is guaranteed to be "good". If an object is "good", then\n
4267 * the chance that the object will be "great" (ego-item or artifact), also\n
4268 * increases with the "level", being equal to half the level, plus 5, up to\n
4269 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4270 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4272 * If the object is not "good", there is a chance it will be "cursed", and\n
4273 * if it is "cursed", there is a chance it will be "broken". These chances\n
4274 * are related to the "good" / "great" chances above.\n
4276 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4277 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4279 * If "okay" is true, and the object is going to be "great", then there is\n
4280 * a chance that an artifact will be created. This is true even if both the\n
4281 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4282 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4284 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4286 int i, rolls, f1, f2, power;
4288 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4290 /* Maximum "level" for various things */
4291 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4293 /* Base chance of being "good" */
4296 /* Maximal chance of being "good" */
4297 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4299 /* Base chance of being "great" */
4302 /* Maximal chance of being "great" */
4303 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4304 f2 = d_info[dungeon_type].obj_great;
4306 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4311 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4320 /* Roll for "good" */
4321 if ((mode & AM_GOOD) || magik(f1))
4326 /* Roll for "great" */
4327 if ((mode & AM_GREAT) || magik(f2))
4331 /* Roll for "special" */
4332 if (mode & AM_SPECIAL) power = 3;
4336 /* Roll for "cursed" */
4339 /* Assume "cursed" */
4342 /* Roll for "broken" */
4343 if (magik(f2)) power = -2;
4347 if (mode & AM_CURSED)
4349 /* Assume 'cursed' */
4354 /* Everything else gets more badly cursed */
4361 /* Assume no rolls */
4364 /* Get one roll if excellent */
4365 if (power >= 2) rolls = 1;
4367 /* Hack -- Get four rolls if forced great or special */
4368 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4370 /* Hack -- Get no rolls if not allowed */
4371 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4373 /* Roll for artifacts if allowed */
4374 for (i = 0; i < rolls; i++)
4376 /* Roll for an artifact */
4377 if (make_artifact(o_ptr)) break;
4378 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4380 if (make_artifact(o_ptr)) break;
4385 /* Hack -- analyze artifacts */
4386 if (object_is_fixed_artifact(o_ptr))
4388 artifact_type *a_ptr = &a_info[o_ptr->name1];
4390 /* Hack -- Mark the artifact as "created" */
4393 /* Hack -- Memorize location of artifact in saved floors */
4394 if (character_dungeon)
4395 a_ptr->floor_id = p_ptr->floor_id;
4397 /* Extract the other fields */
4398 o_ptr->pval = a_ptr->pval;
4399 o_ptr->ac = a_ptr->ac;
4400 o_ptr->dd = a_ptr->dd;
4401 o_ptr->ds = a_ptr->ds;
4402 o_ptr->to_a = a_ptr->to_a;
4403 o_ptr->to_h = a_ptr->to_h;
4404 o_ptr->to_d = a_ptr->to_d;
4405 o_ptr->weight = a_ptr->weight;
4406 o_ptr->xtra2 = a_ptr->act_idx;
4408 if (o_ptr->name1 == ART_MILIM)
4410 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4416 /* Hack -- extract the "broken" flag */
4417 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4419 /* Hack -- extract the "cursed" flag */
4420 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4421 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4422 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4423 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4424 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4425 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4428 /* Cheat -- peek at the item */
4429 if (cheat_peek) object_mention(o_ptr);
4437 switch (o_ptr->tval)
4446 if (power) a_m_aux_1(o_ptr, lev, power);
4452 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4458 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4472 /* Elven Cloak and Black Clothes ... */
4473 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4474 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4475 o_ptr->pval = randint1(4);
4479 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4480 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4481 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4482 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4483 a_m_aux_2(o_ptr, lev, power);
4485 if (power) a_m_aux_2(o_ptr, lev, power);
4493 if (!power && (randint0(100) < 50)) power = -1;
4494 a_m_aux_3(o_ptr, lev, power);
4500 a_m_aux_4(o_ptr, lev, power);
4505 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4506 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4507 (p_ptr->pseikaku == SEIKAKU_SEXY))
4510 add_flag(o_ptr->art_flags, TR_STR);
4511 add_flag(o_ptr->art_flags, TR_INT);
4512 add_flag(o_ptr->art_flags, TR_WIS);
4513 add_flag(o_ptr->art_flags, TR_DEX);
4514 add_flag(o_ptr->art_flags, TR_CON);
4515 add_flag(o_ptr->art_flags, TR_CHR);
4518 /* Hack -- analyze ego-items */
4519 if (object_is_ego(o_ptr))
4521 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4523 /* Hack -- acquire "broken" flag */
4524 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4526 /* Hack -- acquire "cursed" flag */
4527 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4528 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4529 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4530 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4531 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4532 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4534 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4535 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4536 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4537 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4538 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4539 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4540 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4541 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4547 while (one_in_(o_ptr->dd));
4549 if (o_ptr->dd > 9) o_ptr->dd = 9;
4552 /* Hack -- apply activatin index if needed */
4553 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4555 /* Hack -- apply extra penalties if needed */
4556 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4558 /* Hack -- obtain bonuses */
4559 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4560 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4561 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4563 /* Hack -- obtain pval */
4564 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4567 /* Hack -- apply extra bonuses if needed */
4570 /* Hack -- obtain bonuses */
4571 if (e_ptr->max_to_h)
4573 if (e_ptr->max_to_h > 127)
4574 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4575 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4577 if (e_ptr->max_to_d)
4579 if (e_ptr->max_to_d > 127)
4580 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4581 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4583 if (e_ptr->max_to_a)
4585 if (e_ptr->max_to_a > 127)
4586 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4587 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4590 /* Accuracy ego must have high to_h */
4591 if(o_ptr->name2 == EGO_ACCURACY)
4593 while(o_ptr->to_h < o_ptr->to_d + 10)
4598 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4601 /* Accuracy ego must have high to_h */
4602 if(o_ptr->name2 == EGO_VELOCITY)
4604 while(o_ptr->to_d < o_ptr->to_h + 10)
4609 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4612 /* Protection ego must have high to_a */
4613 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4615 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4618 /* Hack -- obtain pval */
4619 if (e_ptr->max_pval)
4621 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4624 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4626 else if (o_ptr->name2 == EGO_DEMON)
4628 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4630 o_ptr->pval += randint1(2);
4634 o_ptr->pval += randint1(e_ptr->max_pval);
4637 else if (o_ptr->name2 == EGO_ATTACKS)
4639 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4640 if (o_ptr->pval > 3) o_ptr->pval = 3;
4641 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4642 o_ptr->pval += randint1(2);
4644 else if (o_ptr->name2 == EGO_BAT)
4646 o_ptr->pval = randint1(e_ptr->max_pval);
4647 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4649 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4651 o_ptr->pval = randint1(e_ptr->max_pval);
4655 o_ptr->pval += randint1(e_ptr->max_pval);
4660 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4662 o_ptr->pval = randint1(o_ptr->pval);
4664 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4668 /* Cheat -- describe the item */
4669 if (cheat_peek) object_mention(o_ptr);
4675 /* Examine real objects */
4678 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4680 /* Hack -- acquire "broken" flag */
4681 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4683 /* Hack -- acquire "cursed" flag */
4684 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4685 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4686 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4687 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4688 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4689 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4695 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4696 * Hack -- determine if a template is "good"
4697 * @param k_idx 判定したいベースアイテムのID
4698 * @return ベースアイテムが上質ならばTRUEを返す。
4700 static bool kind_is_good(int k_idx)
4702 object_kind *k_ptr = &k_info[k_idx];
4704 /* Analyze the item type */
4705 switch (k_ptr->tval)
4707 /* Armor -- Good unless damaged */
4718 if (k_ptr->to_a < 0) return (FALSE);
4722 /* Weapons -- Good unless damaged */
4729 if (k_ptr->to_h < 0) return (FALSE);
4730 if (k_ptr->to_d < 0) return (FALSE);
4734 /* Ammo -- Arrows/Bolts are good */
4741 /* Books -- High level books are good (except Arcane books) */
4743 case TV_SORCERY_BOOK:
4744 case TV_NATURE_BOOK:
4749 case TV_DAEMON_BOOK:
4750 case TV_CRUSADE_BOOK:
4752 case TV_HISSATSU_BOOK:
4755 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4759 /* Rings -- Rings of Speed are good */
4762 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4763 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4767 /* Amulets -- Amulets of the Magi and Resistance are good */
4770 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4771 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4776 /* Assume not good */
4781 * @brief 生成階に応じたベースアイテムの生成を行う。
4782 * Attempt to make an object (normal or good/great)
4783 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4784 * @param mode オプションフラグ
4785 * @return 生成に成功したらTRUEを返す。
4787 * This routine plays nasty games to generate the "special artifacts".\n
4788 * This routine uses "object_level" for the "generation level".\n
4789 * We assume that the given object has been "wiped".\n
4791 bool make_object(object_type *j_ptr, u32b mode)
4797 /* Chance of "special object" */
4798 prob = ((mode & AM_GOOD) ? 10 : 1000);
4800 /* Base level for the object */
4801 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4804 /* Generate a special object, or a normal object */
4805 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4810 if ((mode & AM_GOOD) && !get_obj_num_hook)
4812 /* Activate restriction (if already specified, use that) */
4813 get_obj_num_hook = kind_is_good;
4816 /* Restricted objects - prepare allocation table */
4817 if (get_obj_num_hook) get_obj_num_prep();
4819 /* Pick a random object */
4820 k_idx = get_obj_num(base);
4822 /* Restricted objects */
4823 if (get_obj_num_hook)
4825 /* Clear restriction */
4826 get_obj_num_hook = NULL;
4828 /* Reset allocation table to default */
4832 /* Handle failure */
4833 if (!k_idx) return (FALSE);
4835 /* Prepare the object */
4836 object_prep(j_ptr, k_idx);
4839 /* Apply magic (allow artifacts) */
4840 apply_magic(j_ptr, object_level, mode);
4842 /* Hack -- generate multiple spikes/missiles */
4843 switch (j_ptr->tval)
4851 j_ptr->number = (byte)damroll(6, 7);
4855 obj_level = k_info[j_ptr->k_idx].level;
4856 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4858 /* Notice "okay" out-of-depth objects */
4859 if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
4860 (obj_level > dun_level))
4862 /* Cheat -- peek at items */
4863 if (cheat_peek) object_mention(j_ptr);
4872 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4873 * Attempt to place an object (normal or good/great) at the given location.
4874 * @param y 配置したいフロアのY座標
4875 * @param x 配置したいフロアのX座標
4876 * @param mode オプションフラグ
4877 * @return 生成に成功したらTRUEを返す。
4879 * This routine plays nasty games to generate the "special artifacts".\n
4880 * This routine uses "object_level" for the "generation level".\n
4881 * This routine requires a clean floor grid destination.\n
4883 void place_object(int y, int x, u32b mode)
4888 cave_type *c_ptr = &cave[y][x];
4894 /* Paranoia -- check bounds */
4895 if (!in_bounds(y, x)) return;
4897 /* Require floor space */
4898 if (!cave_drop_bold(y, x)) return;
4900 /* Avoid stacking on other objects */
4901 if (c_ptr->o_idx) return;
4904 /* Get local object */
4907 /* Wipe the object */
4910 /* Make an object (if possible) */
4911 if (!make_object(q_ptr, mode)) return;
4914 /* Make an object */
4922 /* Acquire object */
4923 o_ptr = &o_list[o_idx];
4925 /* Structure Copy */
4926 object_copy(o_ptr, q_ptr);
4933 o_ptr->next_o_idx = c_ptr->o_idx;
4935 /* Place the object */
4936 c_ptr->o_idx = o_idx;
4946 /* Hack -- Preserve artifacts */
4947 if (object_is_fixed_artifact(q_ptr))
4949 a_info[q_ptr->name1].cur_num = 0;
4956 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4957 * Make a treasure object
4958 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4959 * @return 生成に成功したらTRUEを返す。
4961 * The location must be a legal, clean, floor grid.
4963 bool make_gold(object_type *j_ptr)
4970 /* Hack -- Pick a Treasure variety */
4971 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4973 /* Apply "extra" magic */
4974 if (one_in_(GREAT_OBJ))
4976 i += randint1(object_level + 1);
4979 /* Hack -- Creeping Coins only generate "themselves" */
4980 if (coin_type) i = coin_type;
4982 /* Do not create "illegal" Treasure Types */
4983 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4985 /* Prepare a gold object */
4986 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4988 /* Hack -- Base coin cost */
4989 base = k_info[OBJ_GOLD_LIST+i].cost;
4991 /* Determine how much the treasure is "worth" */
4992 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5000 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
5001 * Places a treasure (Gold or Gems) at given location
5002 * @param y 配置したいフロアのY座標
5003 * @param x 配置したいフロアのX座標
5004 * @return 生成に成功したらTRUEを返す。
5006 * The location must be a legal, clean, floor grid.
5008 void place_gold(int y, int x)
5013 cave_type *c_ptr = &cave[y][x];
5020 /* Paranoia -- check bounds */
5021 if (!in_bounds(y, x)) return;
5023 /* Require floor space */
5024 if (!cave_drop_bold(y, x)) return;
5026 /* Avoid stacking on other objects */
5027 if (c_ptr->o_idx) return;
5030 /* Get local object */
5033 /* Wipe the object */
5036 /* Make some gold */
5037 if (!make_gold(q_ptr)) return;
5040 /* Make an object */
5048 /* Acquire object */
5049 o_ptr = &o_list[o_idx];
5051 /* Copy the object */
5052 object_copy(o_ptr, q_ptr);
5059 o_ptr->next_o_idx = c_ptr->o_idx;
5061 /* Place the object */
5062 c_ptr->o_idx = o_idx;
5074 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5075 * Let an object fall to the ground at or near a location.
5076 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5077 * @param chance ドロップの成功率(%)
5078 * @param y 配置したいフロアのY座標
5079 * @param x 配置したいフロアのX座標
5080 * @return 生成に成功したらTRUEを返す。
5082 * The initial location is assumed to be "in_bounds()".\n
5084 * This function takes a parameter "chance". This is the percentage\n
5085 * chance that the item will "disappear" instead of drop. If the object\n
5086 * has been thrown, then this is the chance of disappearance on contact.\n
5088 * Hack -- this function uses "chance" to determine if it should produce\n
5089 * some form of "description" of the drop event (under the player).\n
5091 * We check several locations to see if we can find a location at which\n
5092 * the object can combine, stack, or be placed. Artifacts will try very\n
5093 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5095 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5106 s16b this_o_idx, next_o_idx = 0;
5110 char o_name[MAX_NLEN];
5116 /* Extract plural */
5117 bool plural = (j_ptr->number != 1);
5120 /* Describe object */
5121 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5124 /* Handle normal "breakage" */
5125 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5129 msg_format("%sは消えた。", o_name);
5131 msg_format("The %s disappear%s.",
5132 o_name, (plural ? "" : "s"));
5137 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5154 /* Scan local grids */
5155 for (dy = -3; dy <= 3; dy++)
5157 /* Scan local grids */
5158 for (dx = -3; dx <= 3; dx++)
5162 /* Calculate actual distance */
5163 d = (dy * dy) + (dx * dx);
5165 /* Ignore distant grids */
5166 if (d > 10) continue;
5172 /* Skip illegal grids */
5173 if (!in_bounds(ty, tx)) continue;
5175 /* Require line of projection */
5176 if (!projectable(y, x, ty, tx)) continue;
5179 c_ptr = &cave[ty][tx];
5181 /* Require floor space */
5182 if (!cave_drop_bold(ty, tx)) continue;
5187 /* Scan objects in that grid */
5188 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5192 /* Acquire object */
5193 o_ptr = &o_list[this_o_idx];
5195 /* Acquire next object */
5196 next_o_idx = o_ptr->next_o_idx;
5198 /* Check for possible combination */
5199 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5205 /* Add new object */
5209 if (k > 99) continue;
5211 /* Calculate score */
5212 s = 1000 - (d + k * 5);
5214 /* Skip bad values */
5215 if (s < bs) continue;
5217 /* New best value */
5220 /* Apply the randomizer to equivalent values */
5221 if ((++bn >= 2) && !one_in_(bn)) continue;
5236 /* Handle lack of space */
5237 if (!flag && !object_is_artifact(j_ptr))
5241 msg_format("%sは消えた。", o_name);
5243 msg_format("The %s disappear%s.",
5244 o_name, (plural ? "" : "s"));
5249 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5257 for (i = 0; !flag && (i < 1000); i++)
5260 ty = rand_spread(by, 1);
5261 tx = rand_spread(bx, 1);
5263 /* Verify location */
5264 if (!in_bounds(ty, tx)) continue;
5266 /* Bounce to that location */
5270 /* Require floor space */
5271 if (!cave_drop_bold(by, bx)) continue;
5280 int candidates = 0, pick;
5282 for (ty = 1; ty < cur_hgt - 1; ty++)
5284 for (tx = 1; tx < cur_wid - 1; tx++)
5286 /* A valid space found */
5287 if (cave_drop_bold(ty, tx)) candidates++;
5291 /* No valid place! */
5296 msg_format("%sは消えた。", o_name);
5298 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5302 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5304 /* Mega-Hack -- preserve artifacts */
5307 /* Hack -- Preserve unknown artifacts */
5308 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5310 /* Mega-Hack -- Preserve the artifact */
5311 a_info[j_ptr->name1].cur_num = 0;
5319 /* Choose a random one */
5320 pick = randint1(candidates);
5322 for (ty = 1; ty < cur_hgt - 1; ty++)
5324 for (tx = 1; tx < cur_wid - 1; tx++)
5326 if (cave_drop_bold(ty, tx))
5330 /* Is this a picked one? */
5344 c_ptr = &cave[by][bx];
5346 /* Scan objects in that grid for combination */
5347 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5351 /* Acquire object */
5352 o_ptr = &o_list[this_o_idx];
5354 /* Acquire next object */
5355 next_o_idx = o_ptr->next_o_idx;
5357 /* Check for combination */
5358 if (object_similar(o_ptr, j_ptr))
5360 /* Combine the items */
5361 object_absorb(o_ptr, j_ptr);
5371 /* Get new object */
5372 if (!done) o_idx = o_pop();
5375 if (!done && !o_idx)
5379 msg_format("%sは消えた。", o_name);
5381 msg_format("The %s disappear%s.",
5382 o_name, (plural ? "" : "s"));
5387 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5389 /* Hack -- Preserve artifacts */
5390 if (object_is_fixed_artifact(j_ptr))
5392 a_info[j_ptr->name1].cur_num = 0;
5402 /* Structure copy */
5403 object_copy(&o_list[o_idx], j_ptr);
5405 /* Access new object */
5406 j_ptr = &o_list[o_idx];
5413 j_ptr->held_m_idx = 0;
5416 j_ptr->next_o_idx = c_ptr->o_idx;
5418 /* Place the object */
5419 c_ptr->o_idx = o_idx;
5434 /* Mega-Hack -- no message if "dropped" by player */
5435 /* Message when an object falls under the player */
5436 if (chance && player_bold(by, bx))
5438 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5450 * Scatter some "great" objects near the player
5451 * @param y1 配置したいフロアのY座標
5452 * @param x1 配置したいフロアのX座標
5453 * @param num 獲得の処理回数
5454 * @param great TRUEならば必ず高級品以上を落とす
5455 * @param special TRUEならば必ず特別品を落とす
5456 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5459 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5462 object_type object_type_body;
5463 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5468 /* Get local object */
5469 i_ptr = &object_type_body;
5471 /* Wipe the object */
5474 /* Make a good (or great) object (if possible) */
5475 if (!make_object(i_ptr, mode)) continue;
5479 object_aware(i_ptr);
5480 object_known(i_ptr);
5483 /* Drop the object */
5484 (void)drop_near(i_ptr, -1, y1, x1);
5489 * Scatter some "amusing" objects near the player
5492 #define AMS_NOTHING 0x00 /* No restriction */
5493 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5494 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5495 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5496 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5506 amuse_type amuse_info[] =
5508 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5509 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5510 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5511 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5512 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5513 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5514 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5515 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5516 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5517 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5518 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5519 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5520 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5527 * @param y1 配置したいフロアのY座標
5528 * @param x1 配置したいフロアのX座標
5529 * @param num 誰得の処理回数
5530 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5533 void amusement(int y1, int x1, int num, bool known)
5536 object_type object_type_body;
5539 for (n = 0; amuse_info[n].tval != 0; n++)
5541 t += amuse_info[n].prob;
5547 int i, k_idx, a_idx = 0;
5548 int r = randint0(t);
5549 bool insta_art, fixed_art;
5553 r -= amuse_info[i].prob;
5557 /* Get local object */
5558 i_ptr = &object_type_body;
5560 /* Wipe the object */
5563 /* Wipe the object */
5564 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5566 /* Paranoia - reroll if nothing */
5567 if (!k_idx) continue;
5569 /* Search an artifact index if need */
5570 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5571 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5573 if (insta_art || fixed_art)
5575 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5577 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5578 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5579 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5580 if (a_info[a_idx].cur_num > 0) continue;
5584 if (a_idx >= max_a_idx) continue;
5587 /* Make an object (if possible) */
5588 object_prep(i_ptr, k_idx);
5589 if (a_idx) i_ptr->name1 = a_idx;
5590 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5592 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5594 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5597 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5598 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5602 object_aware(i_ptr);
5603 object_known(i_ptr);
5606 /* Paranoia - reroll if nothing */
5607 if (!(i_ptr->k_idx)) continue;
5609 /* Drop the object */
5610 (void)drop_near(i_ptr, -1, y1, x1);
5617 #define MAX_NORMAL_TRAPS 18
5619 /* See init_feat_variables() in init2.c */
5620 static s16b normal_traps[MAX_NORMAL_TRAPS];
5623 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5626 void init_normal_traps(void)
5630 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5631 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5632 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5633 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5634 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5635 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5636 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5637 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5638 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5639 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5640 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5641 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5642 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5643 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5644 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5645 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5646 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5647 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5651 * @brief 基本トラップをランダムに選択する /
5653 * @return 選択したトラップのID
5655 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5656 * That is, it does not make sense to have spiked pits at 50 feet.\n
5657 * Actually, it is not this routine, but the "trap instantiation"\n
5658 * code, which should also check for "trap doors" on quest levels.\n
5660 s16b choose_random_trap(void)
5667 /* Hack -- pick a trap */
5668 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5670 /* Accept non-trapdoors */
5671 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5673 /* Hack -- no trap doors on special levels */
5674 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5676 /* Hack -- no trap doors on the deepest level */
5677 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5686 * @brief マスに存在するトラップを秘匿する /
5687 * Disclose an invisible trap
5688 * @param y 秘匿したいマスのY座標
5689 * @param x 秘匿したいマスのX座標
5692 void disclose_grid(int y, int x)
5694 cave_type *c_ptr = &cave[y][x];
5696 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5698 /* No longer hidden */
5699 cave_alter_feat(y, x, FF_SECRET);
5701 else if (c_ptr->mimic)
5703 /* No longer hidden */
5715 * @brief マスをトラップを配置する /
5716 * The location must be a legal, naked, floor grid.
5717 * @param y 配置したいマスのY座標
5718 * @param x 配置したいマスのX座標
5720 * Note that all traps start out as "invisible" and "untyped", and then\n
5721 * when they are "discovered" (by detecting them or setting them off),\n
5722 * the trap is "instantiated" as a visible, "typed", trap.\n
5724 void place_trap(int y, int x)
5726 cave_type *c_ptr = &cave[y][x];
5728 /* Paranoia -- verify location */
5729 if (!in_bounds(y, x)) return;
5731 /* Require empty, clean, floor grid */
5732 if (!cave_clean_bold(y, x)) return;
5734 /* Place an invisible trap */
5735 c_ptr->mimic = c_ptr->feat;
5736 c_ptr->feat = choose_random_trap();
5740 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5741 * Describe the charges on an item in the inventory.
5742 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5745 void inven_item_charges(int item)
5747 object_type *o_ptr = &inventory[item];
5749 /* Require staff/wand */
5750 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5752 /* Require known item */
5753 if (!object_is_known(o_ptr)) return;
5756 if (o_ptr->pval <= 0)
5758 msg_print("もう魔力が残っていない。");
5762 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5765 /* Multiple charges */
5766 if (o_ptr->pval != 1)
5768 /* Print a message */
5769 msg_format("You have %d charges remaining.", o_ptr->pval);
5775 /* Print a message */
5776 msg_format("You have %d charge remaining.", o_ptr->pval);
5783 * @brief アイテムの残り所持数メッセージを表示する /
5784 * Describe an item in the inventory.
5785 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5788 void inven_item_describe(int item)
5790 object_type *o_ptr = &inventory[item];
5791 char o_name[MAX_NLEN];
5793 /* Get a description */
5794 object_desc(o_name, o_ptr, 0);
5796 /* Print a message */
5798 /* "no more" の場合はこちらで表示する */
5799 if (o_ptr->number <= 0)
5801 /*FIRST*//*ここはもう通らないかも */
5802 msg_format("もう%sを持っていない。", o_name);
5806 /* アイテム名を英日切り替え機能対応 */
5807 msg_format("まだ %sを持っている。", o_name);
5810 msg_format("You have %s.", o_name);
5816 * @brief アイテムの残り所持数メッセージを表示する /
5817 * Increase the "number" of an item in the inventory
5818 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5822 void inven_item_increase(int item, int num)
5824 object_type *o_ptr = &inventory[item];
5827 num += o_ptr->number;
5830 if (num > 255) num = 255;
5831 else if (num < 0) num = 0;
5834 num -= o_ptr->number;
5836 /* Change the number and weight */
5839 /* Add the number */
5840 o_ptr->number += num;
5842 /* Add the weight */
5843 p_ptr->total_weight += (num * o_ptr->weight);
5845 /* Recalculate bonuses */
5846 p_ptr->update |= (PU_BONUS);
5848 /* Recalculate mana XXX */
5849 p_ptr->update |= (PU_MANA);
5851 /* Combine the pack */
5852 p_ptr->notice |= (PN_COMBINE);
5855 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5857 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5858 if (!o_ptr->number && p_ptr->ele_attack)
5860 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5862 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5864 /* Clear all temporary elemental brands */
5865 set_ele_attack(0, 0);
5873 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5874 * Erase an inventory slot if it has no more items
5875 * @param item 消去したいプレイヤーのアイテム所持スロット
5878 void inven_item_optimize(int item)
5880 object_type *o_ptr = &inventory[item];
5882 /* Only optimize real items */
5883 if (!o_ptr->k_idx) return;
5885 /* Only optimize empty items */
5886 if (o_ptr->number) return;
5888 /* The item is in the pack */
5889 if (item < INVEN_RARM)
5896 /* Slide everything down */
5897 for (i = item; i < INVEN_PACK; i++)
5899 /* Structure copy */
5900 inventory[i] = inventory[i+1];
5903 /* Erase the "final" slot */
5904 object_wipe(&inventory[i]);
5907 p_ptr->window |= (PW_INVEN);
5910 /* The item is being wielded */
5916 /* Erase the empty slot */
5917 object_wipe(&inventory[item]);
5919 /* Recalculate bonuses */
5920 p_ptr->update |= (PU_BONUS);
5922 /* Recalculate torch */
5923 p_ptr->update |= (PU_TORCH);
5925 /* Recalculate mana XXX */
5926 p_ptr->update |= (PU_MANA);
5929 p_ptr->window |= (PW_EQUIP);
5933 p_ptr->window |= (PW_SPELL);
5937 * @brief 床上の魔道具の残り残量メッセージを表示する /
5938 * Describe the charges on an item on the floor.
5939 * @param item メッセージの対象にしたいアイテム所持スロット
5942 void floor_item_charges(int item)
5944 object_type *o_ptr = &o_list[item];
5946 /* Require staff/wand */
5947 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5949 /* Require known item */
5950 if (!object_is_known(o_ptr)) return;
5953 if (o_ptr->pval <= 0)
5955 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5959 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5962 /* Multiple charges */
5963 if (o_ptr->pval != 1)
5965 /* Print a message */
5966 msg_format("There are %d charges remaining.", o_ptr->pval);
5972 /* Print a message */
5973 msg_format("There is %d charge remaining.", o_ptr->pval);
5980 * @brief 床上のアイテムの残り数メッセージを表示する /
5981 * Describe the charges on an item on the floor.
5982 * @param item メッセージの対象にしたいアイテム所持スロット
5985 void floor_item_describe(int item)
5987 object_type *o_ptr = &o_list[item];
5988 char o_name[MAX_NLEN];
5990 /* Get a description */
5991 object_desc(o_name, o_ptr, 0);
5993 /* Print a message */
5995 /* "no more" の場合はこちらで表示を分ける */
5996 if (o_ptr->number <= 0)
5998 msg_format("床上には、もう%sはない。", o_name);
6002 msg_format("床上には、まだ %sがある。", o_name);
6005 msg_format("You see %s.", o_name);
6012 * @brief 床上のアイテムの数を増やす /
6013 * Increase the "number" of an item on the floor
6014 * @param item 増やしたいアイテムの所持スロット
6015 * @param num 増やしたいアイテムの数
6018 void floor_item_increase(int item, int num)
6020 object_type *o_ptr = &o_list[item];
6023 num += o_ptr->number;
6026 if (num > 255) num = 255;
6027 else if (num < 0) num = 0;
6030 num -= o_ptr->number;
6032 /* Change the number */
6033 o_ptr->number += num;
6038 * @brief 床上の数の無くなったアイテムスロットを消去する /
6039 * Optimize an item on the floor (destroy "empty" items)
6040 * @param item 消去したいアイテムの所持スロット
6043 void floor_item_optimize(int item)
6045 object_type *o_ptr = &o_list[item];
6047 /* Paranoia -- be sure it exists */
6048 if (!o_ptr->k_idx) return;
6050 /* Only optimize empty items */
6051 if (o_ptr->number) return;
6053 /* Delete the object */
6054 delete_object_idx(item);
6059 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6060 * Check if we have space for an item in the pack without overflow
6061 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6062 * @return 溢れずに済むならTRUEを返す
6064 bool inven_carry_okay(object_type *o_ptr)
6069 if (inven_cnt < INVEN_PACK) return (TRUE);
6072 for (j = 0; j < INVEN_PACK; j++)
6074 object_type *j_ptr = &inventory[j];
6076 /* Skip non-objects */
6077 if (!j_ptr->k_idx) continue;
6079 /* Check if the two items can be combined */
6080 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6088 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6089 * Check if we have space for an item in the pack without overflow
6090 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6091 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6092 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6093 * @return o_ptrの方が上位ならばTRUEを返す。
6095 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6099 /* Use empty slots */
6100 if (!j_ptr->k_idx) return TRUE;
6102 /* Hack -- readable books always come first */
6103 if ((o_ptr->tval == REALM1_BOOK) &&
6104 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6105 if ((j_ptr->tval == REALM1_BOOK) &&
6106 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6108 if ((o_ptr->tval == REALM2_BOOK) &&
6109 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6110 if ((j_ptr->tval == REALM2_BOOK) &&
6111 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6113 /* Objects sort by decreasing type */
6114 if (o_ptr->tval > j_ptr->tval) return TRUE;
6115 if (o_ptr->tval < j_ptr->tval) return FALSE;
6117 /* Non-aware (flavored) items always come last */
6118 /* Can happen in the home */
6119 if (!object_is_aware(o_ptr)) return FALSE;
6120 if (!object_is_aware(j_ptr)) return TRUE;
6122 /* Objects sort by increasing sval */
6123 if (o_ptr->sval < j_ptr->sval) return TRUE;
6124 if (o_ptr->sval > j_ptr->sval) return FALSE;
6126 /* Unidentified objects always come last */
6127 /* Objects in the home can be unknown */
6128 if (!object_is_known(o_ptr)) return FALSE;
6129 if (!object_is_known(j_ptr)) return TRUE;
6131 /* Fixed artifacts, random artifacts and ego items */
6132 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6133 else if (o_ptr->art_name) o_type = 2;
6134 else if (object_is_ego(o_ptr)) o_type = 1;
6137 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6138 else if (j_ptr->art_name) j_type = 2;
6139 else if (object_is_ego(j_ptr)) j_type = 1;
6142 if (o_type < j_type) return TRUE;
6143 if (o_type > j_type) return FALSE;
6145 switch (o_ptr->tval)
6151 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6152 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6158 /* Objects sort by increasing hit/damage bonuses */
6159 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6160 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6163 /* Hack: otherwise identical rods sort by
6164 increasing recharge time --dsb */
6166 if (o_ptr->pval < j_ptr->pval) return TRUE;
6167 if (o_ptr->pval > j_ptr->pval) return FALSE;
6171 /* Objects sort by decreasing value */
6172 return o_value > object_value(j_ptr);
6177 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6178 * Add an item to the players inventory, and return the slot used.
6179 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6180 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6182 * If the new item can combine with an existing item in the inventory,\n
6183 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6184 * the item will be placed into the "proper" location in the inventory.\n
6186 * This function can be used to "over-fill" the player's pack, but only\n
6187 * once, and such an action must trigger the "overflow" code immediately.\n
6188 * Note that when the pack is being "over-filled", the new item must be\n
6189 * placed into the "overflow" slot, and the "overflow" must take place\n
6190 * before the pack is reordered, but (optionally) after the pack is\n
6191 * combined. This may be tricky. See "dungeon.c" for info.\n
6193 * Note that this code must remove any location/stack information\n
6194 * from the object once it is placed into the inventory.\n
6196 s16b inven_carry(object_type *o_ptr)
6204 /* Check for combining */
6205 for (j = 0; j < INVEN_PACK; j++)
6207 j_ptr = &inventory[j];
6209 /* Skip non-objects */
6210 if (!j_ptr->k_idx) continue;
6212 /* Hack -- track last item */
6215 /* Check if the two items can be combined */
6216 if (object_similar(j_ptr, o_ptr))
6218 /* Combine the items */
6219 object_absorb(j_ptr, o_ptr);
6221 /* Increase the weight */
6222 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6224 /* Recalculate bonuses */
6225 p_ptr->update |= (PU_BONUS);
6228 p_ptr->window |= (PW_INVEN);
6237 if (inven_cnt > INVEN_PACK) return (-1);
6239 /* Find an empty slot */
6240 for (j = 0; j <= INVEN_PACK; j++)
6242 j_ptr = &inventory[j];
6244 /* Use it if found */
6245 if (!j_ptr->k_idx) break;
6252 /* Reorder the pack */
6255 /* Get the "value" of the item */
6256 s32b o_value = object_value(o_ptr);
6258 /* Scan every occupied slot */
6259 for (j = 0; j < INVEN_PACK; j++)
6261 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6268 for (k = n; k >= i; k--)
6270 /* Hack -- Slide the item */
6271 object_copy(&inventory[k+1], &inventory[k]);
6274 /* Wipe the empty slot */
6275 object_wipe(&inventory[i]);
6280 object_copy(&inventory[i], o_ptr);
6282 /* Access new object */
6283 j_ptr = &inventory[i];
6286 j_ptr->next_o_idx = 0;
6288 /* Forget monster */
6289 j_ptr->held_m_idx = 0;
6291 /* Forget location */
6292 j_ptr->iy = j_ptr->ix = 0;
6294 /* Player touches it, and no longer marked */
6295 j_ptr->marked = OM_TOUCHED;
6297 /* Increase the weight */
6298 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6300 /* Count the items */
6303 /* Recalculate bonuses */
6304 p_ptr->update |= (PU_BONUS);
6306 /* Combine and Reorder pack */
6307 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6310 p_ptr->window |= (PW_INVEN);
6312 /* Return the slot */
6318 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6319 * Take off (some of) a non-cursed equipment item
6320 * @param item オブジェクトを外したい所持テーブルのID
6322 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6324 * Note that only one item at a time can be wielded per slot.\n
6325 * Note that taking off an item when "full" may cause that item\n
6326 * to fall to the ground.\n
6327 * Return the inventory slot into which the item is placed.\n
6329 s16b inven_takeoff(int item, int amt)
6340 char o_name[MAX_NLEN];
6343 /* Get the item to take off */
6344 o_ptr = &inventory[item];
6347 if (amt <= 0) return (-1);
6350 if (amt > o_ptr->number) amt = o_ptr->number;
6352 /* Get local object */
6355 /* Obtain a local object */
6356 object_copy(q_ptr, o_ptr);
6358 /* Modify quantity */
6359 q_ptr->number = amt;
6361 /* Describe the object */
6362 object_desc(o_name, q_ptr, 0);
6364 /* Took off weapon */
6365 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6366 object_is_melee_weapon(o_ptr))
6368 act = _("を装備からはずした", "You were wielding");
6372 else if (item == INVEN_BOW)
6374 act = _("を装備からはずした", "You were holding");
6377 /* Took off light */
6378 else if (item == INVEN_LITE)
6380 act = _("を光源からはずした", "You were holding");
6383 /* Took off something */
6386 act = _("を装備からはずした", "You were wearing");
6389 /* Modify, Optimize */
6390 inven_item_increase(item, -amt);
6391 inven_item_optimize(item);
6393 /* Carry the object */
6394 slot = inven_carry(q_ptr);
6398 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6400 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6410 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6411 * Drop (some of) a non-cursed inventory/equipment item
6412 * @param item 所持テーブルのID
6413 * @param amt 落としたい個数
6416 * The object will be dropped "near" the current location
6418 void inven_drop(int item, int amt)
6425 char o_name[MAX_NLEN];
6428 /* Access original object */
6429 o_ptr = &inventory[item];
6432 if (amt <= 0) return;
6435 if (amt > o_ptr->number) amt = o_ptr->number;
6438 /* Take off equipment */
6439 if (item >= INVEN_RARM)
6441 /* Take off first */
6442 item = inven_takeoff(item, amt);
6444 /* Access original object */
6445 o_ptr = &inventory[item];
6449 /* Get local object */
6452 /* Obtain local object */
6453 object_copy(q_ptr, o_ptr);
6455 /* Distribute charges of wands or rods */
6456 distribute_charges(o_ptr, q_ptr, amt);
6458 /* Modify quantity */
6459 q_ptr->number = amt;
6461 /* Describe local object */
6462 object_desc(o_name, q_ptr, 0);
6465 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6467 /* Drop it near the player */
6468 (void)drop_near(q_ptr, 0, py, px);
6470 /* Modify, Describe, Optimize */
6471 inven_item_increase(item, -amt);
6472 inven_item_describe(item);
6473 inven_item_optimize(item);
6478 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6479 * Combine items in the pack
6482 * Note special handling of the "overflow" slot
6484 void combine_pack(void)
6489 bool flag = FALSE, combined;
6495 /* Combine the pack (backwards) */
6496 for (i = INVEN_PACK; i > 0; i--)
6499 o_ptr = &inventory[i];
6501 /* Skip empty items */
6502 if (!o_ptr->k_idx) continue;
6504 /* Scan the items above that item */
6505 for (j = 0; j < i; j++)
6510 j_ptr = &inventory[j];
6512 /* Skip empty items */
6513 if (!j_ptr->k_idx) continue;
6516 * Get maximum number of the stack if these
6517 * are similar, get zero otherwise.
6519 max_num = object_similar_part(j_ptr, o_ptr);
6521 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6522 if (max_num && j_ptr->number < max_num)
6524 if (o_ptr->number + j_ptr->number <= max_num)
6529 /* Add together the item counts */
6530 object_absorb(j_ptr, o_ptr);
6532 /* One object is gone */
6535 /* Slide everything down */
6536 for (k = i; k < INVEN_PACK; k++)
6538 /* Structure copy */
6539 inventory[k] = inventory[k+1];
6542 /* Erase the "final" slot */
6543 object_wipe(&inventory[k]);
6547 int old_num = o_ptr->number;
6548 int remain = j_ptr->number + o_ptr->number - max_num;
6550 o_ptr->number -= remain;
6552 /* Add together the item counts */
6553 object_absorb(j_ptr, o_ptr);
6555 o_ptr->number = remain;
6557 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6558 if (o_ptr->tval == TV_ROD)
6560 o_ptr->pval = o_ptr->pval * remain / old_num;
6561 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6564 /* Hack -- if wands are stacking, combine the charges. -LM- */
6565 if (o_ptr->tval == TV_WAND)
6567 o_ptr->pval = o_ptr->pval * remain / old_num;
6572 p_ptr->window |= (PW_INVEN);
6586 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6590 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6591 * Reorder items in the pack
6594 * Note special handling of the "overflow" slot
6596 void reorder_pack(void)
6606 /* Re-order the pack (forwards) */
6607 for (i = 0; i < INVEN_PACK; i++)
6609 /* Mega-Hack -- allow "proper" over-flow */
6610 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6613 o_ptr = &inventory[i];
6615 /* Skip empty slots */
6616 if (!o_ptr->k_idx) continue;
6618 /* Get the "value" of the item */
6619 o_value = object_value(o_ptr);
6621 /* Scan every occupied slot */
6622 for (j = 0; j < INVEN_PACK; j++)
6624 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6627 /* Never move down */
6628 if (j >= i) continue;
6633 /* Get local object */
6636 /* Save a copy of the moving item */
6637 object_copy(q_ptr, &inventory[i]);
6639 /* Slide the objects */
6640 for (k = i; k > j; k--)
6642 /* Slide the item */
6643 object_copy(&inventory[k], &inventory[k-1]);
6646 /* Insert the moving item */
6647 object_copy(&inventory[j], q_ptr);
6650 p_ptr->window |= (PW_INVEN);
6654 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6658 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6659 * Hack -- display an object kind in the current window
6660 * @param k_idx ベースアイテムの参照ID
6663 * Include list of usable spells for readible books
6665 void display_koff(int k_idx)
6674 char o_name[MAX_NLEN];
6677 /* Erase the window */
6678 for (y = 0; y < Term->hgt; y++)
6680 /* Erase the line */
6681 Term_erase(0, y, 255);
6687 /* Get local object */
6690 /* Prepare the object */
6691 object_prep(q_ptr, k_idx);
6694 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6696 /* Mention the object name */
6697 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6699 /* Access the item's sval */
6701 use_realm = tval2realm(q_ptr->tval);
6703 /* Warriors are illiterate */
6704 if (p_ptr->realm1 || p_ptr->realm2)
6706 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6710 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6711 if (!is_magic(use_realm)) return;
6712 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6715 /* Display spells in readible books */
6721 /* Extract spells */
6722 for (spell = 0; spell < 32; spell++)
6724 /* Check for this spell */
6725 if (fake_spell_flags[sval] & (1L << spell))
6727 /* Collect this spell */
6728 spells[num++] = spell;
6733 print_spells(0, spells, num, 2, 0, use_realm);
6738 * @brief 警告を放つアイテムを選択する /
6739 * Choose one of items that have warning flag
6740 * Calculate spell damages
6743 object_type *choose_warning_item(void)
6746 int choices[INVEN_TOTAL - INVEN_RARM];
6749 /* Paranoia -- Player has no warning ability */
6750 if (!p_ptr->warning) return NULL;
6752 /* Search Inventory */
6753 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6755 u32b flgs[TR_FLAG_SIZE];
6756 object_type *o_ptr = &inventory[i];
6758 object_flags(o_ptr, flgs);
6759 if (have_flag(flgs, TR_WARNING))
6761 choices[number] = i;
6766 /* Choice one of them */
6767 return number ? &inventory[choices[randint0(number)]] : NULL;
6771 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6772 * Calculate spell damages
6773 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6774 * @param typ 効果属性のID
6776 * @param max 算出した最大ダメージを返すポインタ
6779 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int *max)
6781 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6782 int rlev = r_ptr->level;
6783 bool ignore_wraith_form = FALSE;
6785 /* Vulnerability, resistance and immunity */
6789 if (p_ptr->immune_elec)
6792 ignore_wraith_form = TRUE;
6796 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6797 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6798 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6799 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6800 if (IS_OPPOSE_ELEC())
6801 dam = (dam + 2) / 3;
6806 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6807 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6811 if (p_ptr->immune_acid)
6814 ignore_wraith_form = TRUE;
6818 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6819 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6820 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6821 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6827 if (p_ptr->immune_cold)
6830 ignore_wraith_form = TRUE;
6834 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6835 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6836 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6837 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6842 if (p_ptr->immune_fire)
6845 ignore_wraith_form = TRUE;
6849 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6850 if (prace_is_(RACE_ENT)) dam += dam / 3;
6851 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6852 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6853 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6858 ignore_wraith_form = TRUE;
6862 if (!p_ptr->blind &&
6863 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6864 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6867 ignore_wraith_form = TRUE;
6872 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6873 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6874 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6877 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6878 * "dam *= 2;" for later "dam /= 2"
6880 if (p_ptr->wraith_form) dam *= 2;
6884 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6887 ignore_wraith_form = TRUE;
6889 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6893 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6897 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6901 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6905 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6909 if (prace_is_(RACE_SPECTRE))
6912 ignore_wraith_form = TRUE;
6914 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6918 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6922 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6926 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6930 if (p_ptr->levitation) dam = (dam * 2) / 3;
6934 if (p_ptr->resist_shard) dam /= 2;
6938 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6939 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6943 if (p_ptr->mimic_form)
6945 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6948 ignore_wraith_form = TRUE;
6953 switch (p_ptr->prace)
6962 ignore_wraith_form = TRUE;
6969 if (p_ptr->align > 10) dam /= 2;
6970 else if (p_ptr->align < -10) dam *= 2;
6974 if (p_ptr->align > 10) dam *= 2;
6978 case GF_BRAIN_SMASH:
6979 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6982 ignore_wraith_form = TRUE;
6990 if (100 + rlev / 2 <= p_ptr->skill_sav)
6993 ignore_wraith_form = TRUE;
6998 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
7001 ignore_wraith_form = TRUE;
7006 if (p_ptr->wraith_form && !ignore_wraith_form)
7012 if (dam > *max) *max = dam;
7016 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
7017 * Calculate spell damages
7018 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
7019 * @param typ 効果属性のID
7020 * @param m_idx 魔法を行使するモンスターのID
7021 * @param max 算出した最大ダメージを返すポインタ
7024 void spell_damcalc_by_spellnum(int spell_num, int typ, int m_idx, int *max)
7026 monster_type *m_ptr = &m_list[m_idx];
7027 int dam = monspell_damage((spell_num), m_idx, DAM_MAX);
7028 spell_damcalc(m_ptr, typ, dam, max);
7032 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
7033 * Calculate blow damages
7034 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
7035 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
7036 * @return 算出された最大ダメージを返す。
7038 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7040 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7042 bool check_wraith_form = TRUE;
7044 if (blow_ptr->method != RBM_EXPLODE)
7046 int ac = p_ptr->ac + p_ptr->to_a;
7048 switch (blow_ptr->effect)
7052 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7053 dam = MAX(dam, tmp_dam * 2);
7059 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7063 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7065 check_wraith_form = FALSE;
7069 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7071 check_wraith_form = FALSE;
7075 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7077 check_wraith_form = FALSE;
7081 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7083 check_wraith_form = FALSE;
7088 check_wraith_form = FALSE;
7092 if (check_wraith_form && p_ptr->wraith_form)
7100 dam = (dam + 1) / 2;
7101 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7109 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7110 * Examine the grid (xx,yy) and warn the player if there are any danger
7111 * @param xx 危険性を調査するマスのX座標
7112 * @param yy 危険性を調査するマスのY座標
7113 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7115 bool process_warning(int xx, int yy)
7119 char o_name[MAX_NLEN];
7121 #define WARNING_AWARE_RANGE 12
7123 static int old_damage = 0;
7125 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7127 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7130 monster_type *m_ptr;
7131 monster_race *r_ptr;
7133 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7135 c_ptr = &cave[my][mx];
7137 if (!c_ptr->m_idx) continue;
7139 m_ptr = &m_list[c_ptr->m_idx];
7141 if (MON_CSLEEP(m_ptr)) continue;
7142 if (!is_hostile(m_ptr)) continue;
7144 r_ptr = &r_info[m_ptr->r_idx];
7146 /* Monster spells (only powerful ones)*/
7147 if (projectable(my, mx, yy, xx))
7149 u32b f4 = r_ptr->flags4;
7150 u32b f5 = r_ptr->flags5;
7151 u32b f6 = r_ptr->flags6;
7153 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7155 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7156 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7157 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7158 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7159 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7160 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7162 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7163 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7164 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7165 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7166 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7167 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7168 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7169 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7170 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7171 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7172 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7173 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7174 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7175 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7176 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7177 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIA, c_ptr->m_idx, &dam_max0);
7178 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7179 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7180 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7181 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7182 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7183 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7184 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7187 /* Monster melee attacks */
7188 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7190 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7194 for (m = 0; m < 4; m++)
7196 /* Skip non-attacks */
7197 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7199 /* Extract the attack info */
7200 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7201 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7203 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7207 /* Contribution from this monster */
7208 dam_max += dam_max0;
7212 /* Prevent excessive warning */
7213 if (dam_max > old_damage)
7215 old_damage = dam_max * 3 / 2;
7217 if (dam_max > p_ptr->chp / 2)
7219 object_type *o_ptr = choose_warning_item();
7222 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7224 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7225 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7228 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7231 else old_damage = old_damage / 2;
7233 c_ptr = &cave[yy][xx];
7234 if (((!easy_disarm && is_trap(c_ptr->feat))
7235 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7237 object_type *o_ptr = choose_warning_item();
7240 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7242 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7243 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7245 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7252 * @brief エッセンスの付加可能な武器や矢弾かを返す
7253 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7254 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7256 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7258 switch (o_ptr->tval)
7271 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7280 * エッセンス情報の構造体 / A structure for smithing
7283 int add; /* TR flag number or special essence id */
7284 cptr add_name; /* Name of this ability */
7285 int type; /* Menu number */
7286 int essence; /* Index for carrying essences */
7287 int value; /* Needed value to add this ability */
7292 * エッセンス情報テーブル Smithing type data for Weapon smith
7295 static essence_type essence_info[] =
7297 {TR_STR, "腕力", 4, TR_STR, 20},
7298 {TR_INT, "知能", 4, TR_INT, 20},
7299 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7300 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7301 {TR_CON, "耐久力", 4, TR_CON, 20},
7302 {TR_CHR, "魅力", 4, TR_CHR, 20},
7303 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7304 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7305 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7306 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7307 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7308 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7309 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7310 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7311 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7312 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7313 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7314 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7315 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7316 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7317 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7318 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7319 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7320 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7321 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7322 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7323 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7324 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7325 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7326 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7327 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7328 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7329 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7330 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7331 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7332 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7333 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7334 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7335 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7336 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7337 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7338 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7339 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7340 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7341 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7342 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7343 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7344 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7345 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7346 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7347 {TR_SH_FIRE, "", 0, -2, 0},
7348 {TR_SH_ELEC, "", 0, -2, 0},
7349 {TR_SH_COLD, "", 0, -2, 0},
7350 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7351 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7352 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7353 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7354 {TR_LITE_2, "", 0, -2, 0},
7355 {TR_LITE_3, "", 0, -2, 0},
7356 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7357 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7358 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7359 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7360 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7362 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7363 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7364 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7365 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7366 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7367 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7368 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7369 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7370 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7371 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7372 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7373 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7374 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7375 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7376 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7377 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7378 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7379 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7381 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7382 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7383 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7384 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7385 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7386 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7387 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7388 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7390 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7391 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7392 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7393 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7394 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7395 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7396 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7397 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7398 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7399 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7400 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7401 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7403 {-1, NULL, 0, -1, 0}
7406 static essence_type essence_info[] =
7408 {TR_STR, "strength", 4, TR_STR, 20},
7409 {TR_INT, "intelligence", 4, TR_INT, 20},
7410 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7411 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7412 {TR_CON, "constitution", 4, TR_CON, 20},
7413 {TR_CHR, "charisma", 4, TR_CHR, 20},
7414 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7415 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7416 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7417 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7418 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7419 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7420 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7421 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7422 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7423 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7424 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7425 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7426 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7427 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7428 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7429 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7430 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7431 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7432 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7433 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7434 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7435 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7436 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7437 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7438 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7439 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7440 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7441 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7442 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7443 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7444 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7445 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7446 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7447 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7448 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7449 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7450 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7451 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7452 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7453 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7454 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7455 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7456 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7457 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7458 {TR_SH_FIRE, "", 0, -2, 0},
7459 {TR_SH_ELEC, "", 0, -2, 0},
7460 {TR_SH_COLD, "", 0, -2, 0},
7461 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7462 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7463 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7464 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7465 {TR_LITE_2, "", 0, -2, 0},
7466 {TR_LITE_3, "", 0, -2, 0},
7467 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7468 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7469 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7470 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7471 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7473 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7474 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7475 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7476 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7477 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7478 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7479 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7480 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7481 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7482 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7483 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7484 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7485 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7486 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7487 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7488 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7489 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7490 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7492 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7493 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7494 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7495 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7496 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7497 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7498 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7499 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7501 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7502 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7503 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7504 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7505 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7506 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7507 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7508 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7509 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7510 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7511 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7512 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7514 {-1, NULL, 0, -1, 0}
7520 * エッセンス名テーブル / Essense names for Weapon smith
7523 cptr essence_name[] =
7626 cptr essence_name[] =
7729 * @brief 所持しているエッセンス一覧を表示する
7732 static void display_essence(void)
7737 for (i = 1; i < 22; i++)
7741 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7742 "Essence Num Essence Num Essence Num "), 1, 8);
7743 for (i = 0; essence_name[i]; i++)
7745 if (!essence_name[i][0]) continue;
7746 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7749 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7759 static void drain_essence(void)
7761 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7764 bool observe = FALSE;
7765 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7766 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7769 byte iy, ix, marked, number;
7770 s16b next_o_idx, weight;
7772 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7775 item_tester_hook = object_is_weapon_armour_ammo;
7776 item_tester_no_ryoute = TRUE;
7779 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7780 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7782 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7784 /* Get the item (in the pack) */
7787 o_ptr = &inventory[item];
7790 /* Get the item (on the floor) */
7793 o_ptr = &o_list[0 - item];
7796 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7798 char o_name[MAX_NLEN];
7799 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7800 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7803 p_ptr->energy_use = 100;
7805 object_flags(o_ptr, old_flgs);
7806 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7807 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7808 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7809 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7810 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7811 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7812 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7813 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7814 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7816 old_to_a = o_ptr->to_a;
7818 old_to_h = o_ptr->to_h;
7819 old_to_d = o_ptr->to_d;
7822 old_pval = o_ptr->pval;
7823 old_name2 = o_ptr->name2;
7824 old_timeout = o_ptr->timeout;
7825 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7826 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7827 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7828 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7829 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7830 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7831 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7832 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7833 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7834 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7835 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7836 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7837 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7838 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7839 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7840 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7841 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7842 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7843 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7847 next_o_idx = o_ptr->next_o_idx;
7848 marked = o_ptr->marked;
7849 weight = o_ptr->weight;
7850 number = o_ptr->number;
7852 object_prep(o_ptr, o_ptr->k_idx);
7856 o_ptr->next_o_idx=next_o_idx;
7857 o_ptr->marked=marked;
7858 o_ptr->number = number;
7859 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7860 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7861 o_ptr->ident |= (IDENT_MENTAL);
7862 object_aware(o_ptr);
7863 object_known(o_ptr);
7865 object_flags(o_ptr, new_flgs);
7867 for (i = 0; essence_info[i].add_name; i++)
7869 essence_type *es_ptr = &essence_info[i];
7872 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7873 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7875 if (es_ptr->add < TR_FLAG_MAX &&
7876 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7877 have_flag(old_flgs, es_ptr->add))
7881 drain_value[es_ptr->essence] += 10 * pval;
7883 else if (es_ptr->essence != -2)
7885 drain_value[es_ptr->essence] += 10;
7887 else if (es_ptr->add == TR_SH_FIRE)
7889 drain_value[TR_BRAND_FIRE] += 10;
7890 drain_value[TR_RES_FIRE] += 10;
7892 else if (es_ptr->add == TR_SH_ELEC)
7894 drain_value[TR_BRAND_ELEC] += 10;
7895 drain_value[TR_RES_ELEC] += 10;
7897 else if (es_ptr->add == TR_SH_COLD)
7899 drain_value[TR_BRAND_COLD] += 10;
7900 drain_value[TR_RES_COLD] += 10;
7902 else if (es_ptr->add == TR_LITE_2)
7904 drain_value[TR_LITE_1] += 20;
7906 else if (es_ptr->add == TR_LITE_3)
7908 drain_value[TR_LITE_1] += 30;
7913 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7915 drain_value[TR_INT] += 5;
7916 drain_value[TR_WIS] += 5;
7918 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7920 drain_value[TR_BRAND_POIS] += 5;
7921 drain_value[TR_BRAND_ACID] += 5;
7922 drain_value[TR_BRAND_ELEC] += 5;
7923 drain_value[TR_BRAND_FIRE] += 5;
7924 drain_value[TR_BRAND_COLD] += 5;
7926 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7928 drain_value[TR_INT] += 10;
7930 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7932 drain_value[TR_STR] += 10;
7934 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7936 drain_value[TR_DEX] += 10;
7938 if (old_name2 == EGO_2WEAPON)
7940 drain_value[TR_DEX] += 20;
7942 if (object_is_weapon_ammo(o_ptr))
7944 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7946 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7948 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7949 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7950 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7951 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7953 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7955 drain_value[i] *= number;
7956 drain_value[i] = drain_value[i] * dec / 4;
7957 drain_value[i] = MAX(drain_value[i], 0);
7958 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7966 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7970 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7972 for (i = 0; essence_name[i]; i++)
7974 if (!essence_name[i][0]) continue;
7975 if (!drain_value[i]) continue;
7977 p_ptr->magic_num1[i] += drain_value[i];
7978 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7980 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7984 /* Apply autodestroy/inscription to the drained item */
7985 autopick_alter_item(item, TRUE);
7987 /* Combine the pack */
7988 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7991 p_ptr->window |= (PW_INVEN);
7995 * @brief 付加するエッセンスの大別を選択する
7996 * @return 選んだエッセンスの大別ID
7998 static int choose_essence(void)
8002 int menu_line = (use_menu ? 1 : 0);
8005 cptr menu_name[] = {
8015 cptr menu_name[] = {
8025 const int mode_max = 7;
8028 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
8031 #endif /* ALLOW_REPEAT */
8040 for (i = 0; i < mode_max; i++)
8042 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8043 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8045 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8046 prt("Choose from menu.", 0, 0);
8065 menu_line += mode_max - 1;
8074 if (menu_line > mode_max) menu_line -= mode_max;
8085 for (i = 0; i < mode_max; i++)
8086 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8088 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8094 if (isupper(choice)) choice = tolower(choice);
8096 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8097 mode = (int)choice - 'a' + 1;
8104 #endif /* ALLOW_REPEAT */
8109 * @brief エッセンスを実際に付加する
8110 * @param mode エッセンスの大別ID
8113 static void add_essence(int mode)
8115 int item, max_num = 0;
8124 char o_name[MAX_NLEN];
8126 essence_type *es_ptr;
8128 int menu_line = (use_menu ? 1 : 0);
8130 for (i = 0; essence_info[i].add_name; i++)
8132 es_ptr = &essence_info[i];
8134 if (es_ptr->type != mode) continue;
8139 if (!repeat_pull(&i) || i<0 || i>=max_num)
8141 #endif /* ALLOW_REPEAT */
8144 /* Nothing chosen yet */
8150 /* Build a prompt */
8151 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8152 if (use_menu) screen_save();
8154 /* Get a spell from the user */
8156 choice = (always_show_list || use_menu) ? ESCAPE:1;
8160 if( choice==ESCAPE ) choice = ' ';
8161 else if( !get_com(out_val, &choice, FALSE) )break;
8163 if (use_menu && choice != ' ')
8177 menu_line += (max_num-1);
8200 menu_line = max_num;
8214 if (menu_line > max_num) menu_line -= max_num;
8216 /* Request redraw */
8217 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8220 if (!redraw || use_menu)
8224 char dummy[80], dummy2[80];
8232 /* Save the screen */
8233 if (!use_menu) screen_save();
8235 for (y = 1; y < 24; y++)
8238 /* Print header(s) */
8240 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8243 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8246 for (ctr = 0; ctr < max_num; ctr++)
8248 es_ptr = &essence_info[num[ctr]];
8252 if (ctr == (menu_line-1))
8253 strcpy(dummy, _("》 ", "> "));
8254 else strcpy(dummy, " ");
8257 /* letter/number for power selection */
8260 sprintf(dummy, "%c) ",I2A(ctr));
8263 strcat(dummy, es_ptr->add_name);
8268 if (es_ptr->essence != -1)
8270 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8271 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8277 case ESSENCE_SH_FIRE:
8278 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8279 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8280 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8282 case ESSENCE_SH_ELEC:
8283 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8284 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8285 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8287 case ESSENCE_SH_COLD:
8288 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8289 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8290 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8292 case ESSENCE_RESISTANCE:
8293 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8294 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8295 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8296 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8297 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8299 case ESSENCE_SUSTAIN:
8300 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8301 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8302 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8303 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8304 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8309 if (!able[ctr]) col = TERM_RED;
8311 if (es_ptr->essence != -1)
8313 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8317 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8320 c_prt(col, dummy2, ctr+2, x);
8330 /* Restore the screen */
8341 ask = (isupper(choice));
8344 if (ask) choice = tolower(choice);
8346 /* Extract request */
8347 i = (islower(choice) ? A2I(choice) : -1);
8350 /* Totally Illegal */
8351 if ((i < 0) || (i >= max_num) || !able[i])
8363 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8365 /* Belay that order */
8366 if (!get_check(tmp_val)) continue;
8373 /* Restore the screen */
8374 if (redraw) screen_load();
8381 #endif /* ALLOW_REPEAT */
8383 es_ptr = &essence_info[num[i]];
8385 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8386 item_tester_tval = TV_GLOVES;
8387 else if (mode == 1 || mode == 5)
8388 item_tester_hook = item_tester_hook_melee_ammo;
8389 else if (es_ptr->add == ESSENCE_ATTACK)
8390 item_tester_hook = object_allow_enchant_weapon;
8391 else if (es_ptr->add == ESSENCE_AC)
8392 item_tester_hook = object_is_armour;
8394 item_tester_hook = object_is_weapon_armour_ammo;
8395 item_tester_no_ryoute = TRUE;
8398 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8399 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8401 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8403 /* Get the item (in the pack) */
8406 o_ptr = &inventory[item];
8409 /* Get the item (on the floor) */
8412 o_ptr = &o_list[0 - item];
8415 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8417 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8421 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8423 use_essence = es_ptr->value;
8424 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8425 if (o_ptr->number > 1)
8427 use_essence *= o_ptr->number;
8428 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8431 if (es_ptr->essence != -1)
8433 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8435 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8438 if (is_pval_flag(es_ptr->add))
8440 if (o_ptr->pval < 0)
8442 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8445 else if (es_ptr->add == TR_BLOWS)
8447 if (o_ptr->pval > 1)
8449 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8453 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8455 else if (o_ptr->pval > 0)
8457 use_essence *= o_ptr->pval;
8458 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8465 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8467 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8468 strcpy(tmp_val, "1");
8470 if (!get_string(tmp, tmp_val, 1)) return;
8471 pval = atoi(tmp_val);
8472 if (pval > limit) pval = limit;
8473 else if (pval < 1) pval = 1;
8474 o_ptr->pval += pval;
8475 use_essence *= pval;
8476 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8479 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8481 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8485 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8489 int get_to_h, get_to_d;
8491 strcpy(tmp_val, "1");
8492 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8493 val = atoi(tmp_val);
8494 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8495 else if (val < 1) val = 1;
8497 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."));
8503 get_to_h = ((val+1)/2+randint0(val/2+1));
8504 get_to_d = ((val+1)/2+randint0(val/2+1));
8505 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8506 o_ptr->to_h += get_to_h;
8507 o_ptr->to_d += get_to_d;
8509 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8510 if (es_ptr->add == ESSENCE_ATTACK)
8512 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8514 msg_print(_("改良に失敗した。", "You failed to enchant."));
8515 p_ptr->energy_use = 100;
8520 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8521 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8524 else if (es_ptr->add == ESSENCE_AC)
8526 if (o_ptr->to_a >= p_ptr->lev/5+5)
8528 msg_print(_("改良に失敗した。", "You failed to enchant."));
8529 p_ptr->energy_use = 100;
8534 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8539 o_ptr->xtra3 = es_ptr->add + 1;
8544 bool success = TRUE;
8548 case ESSENCE_SH_FIRE:
8549 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8554 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8555 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8557 case ESSENCE_SH_ELEC:
8558 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8563 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8564 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8566 case ESSENCE_SH_COLD:
8567 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8572 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8573 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8575 case ESSENCE_RESISTANCE:
8576 case ESSENCE_SUSTAIN:
8577 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))
8582 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8583 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8584 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8585 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8590 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8593 if (es_ptr->add == ESSENCE_SUSTAIN)
8595 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8596 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8597 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8598 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8602 o_ptr->xtra3 = es_ptr->add + 1;
8606 p_ptr->energy_use = 100;
8609 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8611 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8614 /* Combine the pack */
8615 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8618 p_ptr->window |= (PW_INVEN);
8625 static void erase_essence(void)
8630 char o_name[MAX_NLEN];
8631 u32b flgs[TR_FLAG_SIZE];
8633 item_tester_hook = object_is_smith;
8636 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8637 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8639 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8641 /* Get the item (in the pack) */
8644 o_ptr = &inventory[item];
8647 /* Get the item (on the floor) */
8650 o_ptr = &o_list[0 - item];
8653 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8654 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8656 p_ptr->energy_use = 100;
8658 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8660 o_ptr->to_h -= (o_ptr->xtra4>>8);
8661 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8663 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8664 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8667 object_flags(o_ptr, flgs);
8668 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8669 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8671 /* Combine the pack */
8672 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8675 p_ptr->window |= (PW_INVEN);
8679 * @brief 鍛冶コマンドのメインルーチン
8680 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8683 void do_cmd_kaji(bool only_browse)
8688 int menu_line = (use_menu ? 1 : 0);
8692 if (p_ptr->confused)
8694 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8699 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8704 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8710 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8712 #endif /* ALLOW_REPEAT */
8714 if (only_browse) screen_save();
8716 if (!only_browse) screen_save();
8722 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8723 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8724 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8725 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8726 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8727 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8729 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8730 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8731 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8732 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8733 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8734 prt(format("Choose command from menu."), 0, 0);
8761 if (menu_line > 5) menu_line -= 5;
8770 prt(" a) エッセンス一覧", 2, 14);
8771 prt(" b) エッセンス抽出", 3, 14);
8772 prt(" c) エッセンス消去", 4, 14);
8773 prt(" d) エッセンス付加", 5, 14);
8774 prt(" e) 武器/防具強化", 6, 14);
8775 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8777 prt(" a) List essences", 2, 14);
8778 prt(" b) Extract essence", 3, 14);
8779 prt(" c) Remove essence", 4, 14);
8780 prt(" d) Add essence", 5, 14);
8781 prt(" e) Enchant weapon/armor", 6, 14);
8782 if (!get_com("Command :", &choice, TRUE))
8819 /* Clear lines, position cursor (really should use strlen here) */
8820 Term_erase(14, 21, 255);
8821 Term_erase(14, 20, 255);
8822 Term_erase(14, 19, 255);
8823 Term_erase(14, 18, 255);
8824 Term_erase(14, 17, 255);
8825 Term_erase(14, 16, 255);
8827 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8828 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8830 prt(&temp[j], line, 15);
8835 if (!only_browse) screen_load();
8836 } while (only_browse);
8840 #endif /* ALLOW_REPEAT */
8844 case 1: display_essence();break;
8845 case 2: drain_essence();break;
8846 case 3: erase_essence();break;
8848 mode = choose_essence();
8853 case 5: add_essence(10);break;
8859 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8860 * Torches have special abilities when they are flaming.
8861 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8862 * @param flgs 特別に追加するフラグを返す参照ポインタ
8865 void torch_flags(object_type *o_ptr, u32b *flgs)
8867 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8869 if (o_ptr->xtra4 > 0)
8871 add_flag(flgs, TR_BRAND_FIRE);
8872 add_flag(flgs, TR_KILL_UNDEAD);
8873 add_flag(flgs, TR_THROW);
8879 * @brief 投擲時たいまつにダイスを与える。
8880 * Torches have special abilities when they are flaming.
8881 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8882 * @param dd 特別なダイス数を返す参照ポインタ
8883 * @param ds 特別なダイス面数を返す参照ポインタ
8886 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8888 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8890 if (o_ptr->xtra4 > 0)
8899 * @brief 投擲時命中したたいまつの寿命を縮める。
8900 * Torches have special abilities when they are flaming.
8901 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8904 void torch_lost_fuel(object_type *o_ptr)
8906 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8908 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8909 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;