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
2101 * @todo 生成基準を dun_level から obj_level に直すか検討。
2103 static bool make_artifact_special(object_type *o_ptr)
2108 /*! @note 地上ではキャンセルする / No artifacts in the town */
2109 if (!dun_level) return (FALSE);
2111 /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
2112 if (get_obj_num_hook) return (FALSE);
2114 /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
2115 for (i = 0; i < max_a_idx; i++)
2117 artifact_type *a_ptr = &a_info[i];
2119 /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
2120 if (!a_ptr->name) continue;
2122 /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
2123 if (a_ptr->cur_num) continue;
2124 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2125 if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
2127 /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
2128 * XXX XXX Enforce minimum "depth" (loosely) */
2129 if (a_ptr->level > dun_level)
2131 /* @note / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2132 int d = (a_ptr->level - dun_level) * 2;
2133 if (!one_in_(d)) continue;
2136 /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
2137 if (!one_in_(a_ptr->rarity)) continue;
2139 /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
2140 * Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
2141 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
2142 if (k_info[k_idx].level > object_level)
2144 int d = (k_info[k_idx].level - object_level) * 5;
2145 if (!one_in_(d)) continue;
2148 /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
2149 * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
2150 object_prep(o_ptr, k_idx);
2153 random_artifact_resistance(o_ptr, a_ptr);
2157 /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
2163 * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
2164 * Mega-Hack -- Attempt to create one of the "Special Objects"
2165 * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
2166 * @return 生成に成功したらTRUEを返す。
2168 * Attempt to change an object into an artifact\n
2169 * This routine should only be called by "apply_magic()"\n
2170 * Note -- see "make_artifact_special()" and "apply_magic()"\n
2172 static bool make_artifact(object_type *o_ptr)
2177 /* No artifacts in the town */
2178 if (!dun_level) return (FALSE);
2180 /* Paranoia -- no "plural" artifacts */
2181 if (o_ptr->number != 1) return (FALSE);
2183 /* Check the artifact list (skip the "specials") */
2184 for (i = 0; i < max_a_idx; i++)
2186 artifact_type *a_ptr = &a_info[i];
2188 /* Skip "empty" items */
2189 if (!a_ptr->name) continue;
2191 /* Cannot make an artifact twice */
2192 if (a_ptr->cur_num) continue;
2194 if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
2196 if (a_ptr->gen_flags & TRG_INSTA_ART) continue;
2198 /* Must have the correct fields */
2199 if (a_ptr->tval != o_ptr->tval) continue;
2200 if (a_ptr->sval != o_ptr->sval) continue;
2202 /* XXX XXX Enforce minimum "depth" (loosely) */
2203 if (a_ptr->level > dun_level)
2205 /* Acquire the "out-of-depth factor" */
2206 int d = (a_ptr->level - dun_level) * 2;
2208 /* Roll for out-of-depth creation */
2209 if (!one_in_(d)) continue;
2212 /* We must make the "rarity roll" */
2213 if (!one_in_(a_ptr->rarity)) continue;
2215 /* Hack -- mark the item as an artifact */
2218 /* Hack: Some artifacts get random extra powers */
2219 random_artifact_resistance(o_ptr, a_ptr);
2231 * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
2232 * Choose random ego type
2233 * @param slot 取得したいエゴの装備部位
2234 * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
2235 * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
2237 static byte get_random_ego(byte slot, bool good)
2240 ego_item_type *e_ptr;
2244 for (i = 1; i < max_e_idx; i++)
2248 if (e_ptr->slot == slot
2249 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2252 total += (255 / e_ptr->rarity);
2256 value = randint1(total);
2258 for (i = 1; i < max_e_idx; i++)
2262 if (e_ptr->slot == slot
2263 && ((good && e_ptr->rating) || (!good && !e_ptr->rating)) )
2266 value -= (255 / e_ptr->rarity);
2267 if (value <= 0L) break;
2275 * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2276 * Apply magic to an item known to be a "weapon"
2277 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2278 * @param level 生成基準階
2279 * @param power 生成ランク
2282 * Hack -- note special base damage dice boosting\n
2283 * Hack -- note special processing for weapon/digger\n
2285 static void a_m_aux_1(object_type *o_ptr, int level, int power)
2287 int tohit1 = randint1(5) + m_bonus(5, level);
2288 int todam1 = randint1(5) + m_bonus(5, level);
2290 int tohit2 = m_bonus(10, level);
2291 int todam2 = m_bonus(10, level);
2293 if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
2295 tohit2 = (tohit2+1)/2;
2296 todam2 = (todam2+1)/2;
2303 o_ptr->to_h += tohit1;
2304 o_ptr->to_d += todam1;
2310 o_ptr->to_h += tohit2;
2311 o_ptr->to_d += todam2;
2319 o_ptr->to_h -= tohit1;
2320 o_ptr->to_d -= todam1;
2325 /* Penalize again */
2326 o_ptr->to_h -= tohit2;
2327 o_ptr->to_d -= todam2;
2330 /* Cursed (if "bad") */
2331 if (o_ptr->to_h + o_ptr->to_d < 0) o_ptr->curse_flags |= TRC_CURSED;
2334 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)) return;
2337 switch (o_ptr->tval)
2344 if (one_in_(30) || (power > 2)) /* power > 2 is debug only */
2345 create_artifact(o_ptr, FALSE);
2347 /* Special Ego-item */
2348 o_ptr->name2 = EGO_DIGGING;
2352 else if (power < -1)
2354 /* Hack -- Horrible digging bonus */
2355 o_ptr->pval = 0 - (5 + randint1(5));
2361 /* Hack -- Reverse digging bonus */
2362 o_ptr->pval = 0 - (o_ptr->pval);
2376 if (one_in_(40) || (power > 2)) /* power > 2 is debug only */
2378 create_artifact(o_ptr, FALSE);
2383 /* Roll for an ego-item */
2384 o_ptr->name2 = get_random_ego(INVEN_RARM, TRUE);
2385 if (o_ptr->name2 == EGO_SHARPNESS && o_ptr->tval != TV_SWORD)
2387 if (o_ptr->name2 == EGO_EARTHQUAKES && o_ptr->tval != TV_HAFTED)
2389 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2394 switch (o_ptr->name2)
2397 if (one_in_(4) && (level > 40))
2398 add_flag(o_ptr->art_flags, TR_BLOWS);
2402 add_flag(o_ptr->art_flags, TR_RES_POIS);
2404 add_flag(o_ptr->art_flags, TR_WARNING);
2406 case EGO_KILL_DRAGON:
2408 add_flag(o_ptr->art_flags, TR_RES_POIS);
2412 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2414 case EGO_SLAYING_WEAPON:
2415 if (one_in_(3)) /* double damage */
2423 while (one_in_(o_ptr->dd));
2429 while (one_in_(o_ptr->ds));
2434 add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2436 if (o_ptr->tval == TV_SWORD && one_in_(3))
2438 add_flag(o_ptr->art_flags, TR_VORPAL);
2443 add_flag(o_ptr->art_flags, TR_SLAY_DEMON);
2449 add_flag(o_ptr->art_flags, TR_HOLD_EXP);
2451 add_flag(o_ptr->art_flags, TR_DEX);
2453 add_flag(o_ptr->art_flags, TR_RES_FEAR);
2456 o_ptr->pval = m_bonus(5, level) + 1;
2458 case EGO_EARTHQUAKES:
2459 if (one_in_(3) && (level > 60))
2460 add_flag(o_ptr->art_flags, TR_BLOWS);
2462 o_ptr->pval = m_bonus(3, level);
2466 add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
2470 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2472 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2474 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2475 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2478 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CHAOTIC);
2479 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BLOWS);
2480 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2481 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2485 if (!o_ptr->art_name)
2487 /* Hack -- Super-charge the damage dice */
2488 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2490 /* Hack -- Lower the damage dice */
2491 if (o_ptr->dd > 9) o_ptr->dd = 9;
2496 else if (power < -1)
2498 /* Roll for ego-item */
2499 if (randint0(MAX_DEPTH) < level)
2503 o_ptr->name2 = get_random_ego(INVEN_RARM, FALSE);
2504 if (o_ptr->name2 == EGO_WEIRD && o_ptr->tval != TV_SWORD)
2510 switch (o_ptr->name2)
2513 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2514 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2516 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_BRAND_POIS);
2517 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_NETHER);
2518 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2519 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2520 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2521 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2535 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2537 create_artifact(o_ptr, FALSE);
2540 o_ptr->name2 = get_random_ego(INVEN_BOW, TRUE);
2554 if (power > 2) /* power > 2 is debug only */
2556 create_artifact(o_ptr, FALSE);
2560 o_ptr->name2 = get_random_ego(INVEN_AMMO, TRUE);
2562 switch (o_ptr->name2)
2564 case EGO_SLAYING_BOLT:
2569 /* Hack -- super-charge the damage dice */
2570 while (one_in_(10L * o_ptr->dd * o_ptr->ds)) o_ptr->dd++;
2572 /* Hack -- restrict the damage dice */
2573 if (o_ptr->dd > 9) o_ptr->dd = 9;
2577 else if (power < -1)
2579 /* Roll for ego-item */
2580 if (randint0(MAX_DEPTH) < level)
2582 o_ptr->name2 = get_random_ego(INVEN_AMMO, FALSE);
2592 * @brief ドラゴン装備にランダムな耐性を与える
2593 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2596 static void dragon_resist(object_type * o_ptr)
2601 one_dragon_ele_resistance(o_ptr);
2603 one_high_resistance(o_ptr);
2609 * @brief オブジェクトにランダムな強いESPを与える
2610 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2613 static bool add_esp_strong(object_type *o_ptr)
2615 bool nonliv = FALSE;
2617 switch (randint1(3))
2619 case 1: add_flag(o_ptr->art_flags, TR_ESP_EVIL); break;
2620 case 2: add_flag(o_ptr->art_flags, TR_TELEPATHY); break;
2621 case 3: add_flag(o_ptr->art_flags, TR_ESP_NONLIVING); nonliv = TRUE; break;
2628 * @brief オブジェクトにランダムな弱いESPを与える
2629 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2630 * @param extra TRUEならばESPの最大付与数が増える(TRUE -> 3+1d6 / FALSE -> 1d3)
2633 static void add_esp_weak(object_type *o_ptr, bool extra)
2636 u32b weak_esp_list[] = {
2648 const int MAX_ESP_WEAK = sizeof(weak_esp_list) / sizeof(weak_esp_list[0]);
2649 const int add_count = MIN(MAX_ESP_WEAK, (extra) ? (3 + randint1(randint1(6))) : randint1(3));
2651 /* Add unduplicated weak esp flags randomly */
2652 for (i = 0; i < add_count; ++ i)
2654 int choice = rand_range(i, MAX_ESP_WEAK - 1);
2656 add_flag(o_ptr->art_flags, weak_esp_list[choice]);
2657 weak_esp_list[choice] = weak_esp_list[i];
2663 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
2664 * Apply magic to an item known to be "armor"
2665 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
2666 * @param level 生成基準階
2667 * @param power 生成ランク
2670 * Hack -- note special processing for crown/helm\n
2671 * Hack -- note special processing for robe of permanence\n
2673 static void a_m_aux_2(object_type *o_ptr, int level, int power)
2675 int toac1 = randint1(5) + m_bonus(5, level);
2677 int toac2 = m_bonus(10, level);
2683 o_ptr->to_a += toac1;
2689 o_ptr->to_a += toac2;
2697 o_ptr->to_a -= toac1;
2702 /* Penalize again */
2703 o_ptr->to_a -= toac2;
2706 /* Cursed (if "bad") */
2707 if (o_ptr->to_a < 0) o_ptr->curse_flags |= TRC_CURSED;
2712 switch (o_ptr->tval)
2716 if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
2717 create_artifact(o_ptr, FALSE);
2719 /* Mention the item */
2720 if (cheat_peek) object_mention(o_ptr);
2731 /* Hack -- Try for "Robes of the Magi" */
2732 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
2733 (o_ptr->sval == SV_ROBE) &&
2734 (randint0(100) < 15))
2738 o_ptr->name2 = EGO_YOIYAMI;
2739 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
2740 o_ptr->sval = SV_YOIYAMI_ROBE;
2746 o_ptr->name2 = EGO_PERMANENCE;
2751 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2753 create_artifact(o_ptr, FALSE);
2759 bool okay_flag = TRUE;
2761 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
2763 switch (o_ptr->name2)
2766 if (o_ptr->tval != TV_HARD_ARMOR)
2772 if (o_ptr->tval != TV_SOFT_ARMOR)
2784 switch (o_ptr->name2)
2786 case EGO_RESISTANCE:
2788 add_flag(o_ptr->art_flags, TR_RES_POIS);
2791 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2792 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
2796 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2798 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
2800 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
2801 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2803 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2804 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
2805 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2806 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
2807 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
2808 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
2809 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2810 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
2813 if (one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
2814 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
2815 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
2816 if (one_in_(6)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
2817 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
2818 if (one_in_(9)) add_flag(o_ptr->art_flags, TR_NO_TELE);
2831 if (o_ptr->sval == SV_DRAGON_SHIELD)
2833 /* Mention the item */
2834 if (cheat_peek) object_mention(o_ptr);
2835 dragon_resist(o_ptr);
2836 if (!one_in_(3)) break;
2842 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2844 create_artifact(o_ptr, FALSE);
2850 o_ptr->name2 = get_random_ego(INVEN_LARM, TRUE);
2851 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD
2852 && o_ptr->name2 == EGO_S_DWARVEN)
2859 switch (o_ptr->name2)
2862 if (!one_in_(3)) one_high_resistance(o_ptr);
2863 if (one_in_(4)) add_flag(o_ptr->art_flags, TR_RES_POIS);
2865 case EGO_REFLECTION:
2866 if (o_ptr->sval == SV_MIRROR_SHIELD)
2871 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
2872 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
2881 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
2883 /* Mention the item */
2884 if (cheat_peek) object_mention(o_ptr);
2885 dragon_resist(o_ptr);
2886 if (!one_in_(3)) break;
2890 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2892 create_artifact(o_ptr, FALSE);
2895 o_ptr->name2 = get_random_ego(INVEN_HANDS, TRUE);
2899 else if (power < -1)
2901 o_ptr->name2 = get_random_ego(INVEN_HANDS, FALSE);
2909 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
2911 /* Mention the item */
2912 if (cheat_peek) object_mention(o_ptr);
2913 dragon_resist(o_ptr);
2914 if (!one_in_(3)) break;
2919 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2921 create_artifact(o_ptr, FALSE);
2924 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
2926 switch (o_ptr->name2)
2928 case EGO_SLOW_DESCENT:
2931 one_high_resistance(o_ptr);
2937 else if (power < -1)
2939 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
2950 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
2952 create_artifact(o_ptr, FALSE);
2957 bool ok_flag = TRUE;
2958 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
2960 switch (o_ptr->name2)
2963 if (add_esp_strong(o_ptr)) add_esp_weak(o_ptr, TRUE);
2964 else add_esp_weak(o_ptr, FALSE);
2968 case EGO_REGENERATION:
2969 case EGO_LORDLINESS:
2975 if (one_in_(2)) add_esp_strong(o_ptr);
2976 else add_esp_weak(o_ptr, FALSE);
2979 default:/* not existing crown (wisdom,lite, etc...) */
2983 break; /* while (1) */
2989 else if (power < -1)
2993 bool ok_flag = TRUE;
2994 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
2996 switch (o_ptr->name2)
2998 case EGO_ANCIENT_CURSE:
2999 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_MAGIC);
3000 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_NO_TELE);
3001 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3002 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3003 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3004 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3008 break; /* while (1) */
3017 if (o_ptr->sval == SV_DRAGON_HELM)
3019 /* Mention the item */
3020 if (cheat_peek) object_mention(o_ptr);
3021 dragon_resist(o_ptr);
3022 if (!one_in_(3)) break;
3028 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3030 create_artifact(o_ptr, FALSE);
3035 bool ok_flag = TRUE;
3036 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
3038 switch (o_ptr->name2)
3040 case EGO_BRILLIANCE:
3042 case EGO_INFRAVISION:
3043 case EGO_H_PROTECTION:
3048 if (one_in_(2)) add_esp_strong(o_ptr);
3049 else add_esp_weak(o_ptr, FALSE);
3053 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_1);
3054 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_LITE_2);
3057 if(one_in_(3)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
3059 add_flag(o_ptr->art_flags, TR_DRAIN_EXP) :
3061 add_flag(o_ptr->art_flags, TR_DRAIN_HP) :
3062 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3064 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_AGGRAVATE);
3065 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
3066 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
3067 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_HP);
3068 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
3069 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3070 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_TY_CURSE);
3071 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_CALL_DEMON);
3073 default:/* not existing helm (Magi, Might, etc...)*/
3077 break; /* while (1) */
3082 else if (power < -1)
3086 bool ok_flag = TRUE;
3087 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
3089 switch (o_ptr->name2)
3091 case EGO_ANCIENT_CURSE:
3095 break; /* while (1) */
3106 if (one_in_(20) || (power > 2)) /* power > 2 is debug only */
3108 create_artifact(o_ptr, FALSE);
3111 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
3113 switch (o_ptr->name2)
3122 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
3123 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
3124 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
3125 if (one_in_(3)) add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
3132 else if (power < -1)
3134 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);
3144 * @brief 装飾品系オブジェクトに生成ランクごとの強化を与えるサブルーチン
3145 * Apply magic to an item known to be a "ring" or "amulet"
3146 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3147 * @param level 生成基準階
3148 * @param power 生成ランク
3151 * Hack -- note special "pval boost" code for ring of speed\n
3152 * Hack -- note that some items must be cursed (or blessed)\n
3154 static void a_m_aux_3(object_type *o_ptr, int level, int power)
3156 /* Apply magic (good or bad) according to type */
3157 switch (o_ptr->tval)
3162 switch (o_ptr->sval)
3164 case SV_RING_ATTACKS:
3167 o_ptr->pval = m_bonus(2, level);
3168 if (one_in_(15)) o_ptr->pval++;
3169 if (o_ptr->pval < 1) o_ptr->pval = 1;
3175 o_ptr->ident |= (IDENT_BROKEN);
3178 o_ptr->curse_flags |= TRC_CURSED;
3181 o_ptr->pval = 0 - (o_ptr->pval);
3192 /* Strength, Constitution, Dexterity, Intelligence */
3198 o_ptr->pval = 1 + m_bonus(5, level);
3204 o_ptr->ident |= (IDENT_BROKEN);
3207 o_ptr->curse_flags |= TRC_CURSED;
3210 o_ptr->pval = 0 - (o_ptr->pval);
3216 /* Ring of Speed! */
3219 /* Base speed (1 to 10) */
3220 o_ptr->pval = randint1(5) + m_bonus(5, level);
3222 /* Super-charge the ring */
3223 while (randint0(100) < 50) o_ptr->pval++;
3229 o_ptr->ident |= (IDENT_BROKEN);
3232 o_ptr->curse_flags |= TRC_CURSED;
3235 o_ptr->pval = 0 - (o_ptr->pval);
3240 /* Mention the item */
3241 if (cheat_peek) object_mention(o_ptr);
3246 case SV_RING_LORDLY:
3250 one_lordly_high_resistance(o_ptr);
3254 /* Bonus to armor class */
3255 o_ptr->to_a = 10 + randint1(5) + m_bonus(10, level);
3259 case SV_RING_WARNING:
3261 if (one_in_(3)) one_low_esp(o_ptr);
3266 case SV_RING_SEARCHING:
3268 /* Bonus to searching */
3269 o_ptr->pval = 1 + m_bonus(5, level);
3275 o_ptr->ident |= (IDENT_BROKEN);
3278 o_ptr->curse_flags |= TRC_CURSED;
3281 o_ptr->pval = 0 - (o_ptr->pval);
3287 /* Flames, Acid, Ice */
3288 case SV_RING_FLAMES:
3293 /* Bonus to armor class */
3294 o_ptr->to_a = 5 + randint1(5) + m_bonus(10, level);
3298 /* Weakness, Stupidity */
3299 case SV_RING_WEAKNESS:
3300 case SV_RING_STUPIDITY:
3303 o_ptr->ident |= (IDENT_BROKEN);
3306 o_ptr->curse_flags |= TRC_CURSED;
3309 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3310 if (power > 0) power = 0 - power;
3315 /* WOE, Stupidity */
3319 o_ptr->ident |= (IDENT_BROKEN);
3322 o_ptr->curse_flags |= TRC_CURSED;
3325 o_ptr->to_a = 0 - (5 + m_bonus(10, level));
3326 o_ptr->pval = 0 - (1 + m_bonus(5, level));
3327 if (power > 0) power = 0 - power;
3332 /* Ring of damage */
3333 case SV_RING_DAMAGE:
3335 /* Bonus to damage */
3336 o_ptr->to_d = 1 + randint1(5) + m_bonus(16, level);
3342 o_ptr->ident |= (IDENT_BROKEN);
3345 o_ptr->curse_flags |= TRC_CURSED;
3348 o_ptr->to_d = 0 - o_ptr->to_d;
3354 /* Ring of Accuracy */
3355 case SV_RING_ACCURACY:
3358 o_ptr->to_h = 1 + randint1(5) + m_bonus(16, level);
3364 o_ptr->ident |= (IDENT_BROKEN);
3367 o_ptr->curse_flags |= TRC_CURSED;
3370 o_ptr->to_h = 0 - o_ptr->to_h;
3376 /* Ring of Protection */
3377 case SV_RING_PROTECTION:
3379 /* Bonus to armor class */
3380 o_ptr->to_a = 5 + randint1(8) + m_bonus(10, level);
3386 o_ptr->ident |= (IDENT_BROKEN);
3389 o_ptr->curse_flags |= TRC_CURSED;
3392 o_ptr->to_a = 0 - o_ptr->to_a;
3398 /* Ring of Slaying */
3399 case SV_RING_SLAYING:
3401 /* Bonus to damage and to hit */
3402 o_ptr->to_d = randint1(5) + m_bonus(12, level);
3403 o_ptr->to_h = randint1(5) + m_bonus(12, level);
3409 o_ptr->ident |= (IDENT_BROKEN);
3412 o_ptr->curse_flags |= TRC_CURSED;
3414 /* Reverse bonuses */
3415 o_ptr->to_h = 0 - o_ptr->to_h;
3416 o_ptr->to_d = 0 - o_ptr->to_d;
3422 case SV_RING_MUSCLE:
3424 o_ptr->pval = 1 + m_bonus(3, level);
3425 if (one_in_(4)) o_ptr->pval++;
3431 o_ptr->ident |= (IDENT_BROKEN);
3434 o_ptr->curse_flags |= TRC_CURSED;
3436 /* Reverse bonuses */
3437 o_ptr->pval = 0 - o_ptr->pval;
3442 case SV_RING_AGGRAVATION:
3445 o_ptr->ident |= (IDENT_BROKEN);
3448 o_ptr->curse_flags |= TRC_CURSED;
3450 if (power > 0) power = 0 - power;
3454 if ((one_in_(400) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3455 || (power > 2)) /* power > 2 is debug only */
3457 o_ptr->pval = MIN(o_ptr->pval, 4);
3458 /* Randart amulet */
3459 create_artifact(o_ptr, FALSE);
3461 else if ((power == 2) && one_in_(2))
3463 while(!o_ptr->name2)
3465 int tmp = m_bonus(10, level);
3466 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3467 switch(randint1(28))
3470 o_ptr->name2 = EGO_RING_THROW;
3473 if (have_flag(k_ptr->flags, TR_REGEN)) break;
3474 o_ptr->name2 = EGO_RING_REGEN;
3477 if (have_flag(k_ptr->flags, TR_LITE_1)) break;
3478 o_ptr->name2 = EGO_RING_LITE;
3481 if (have_flag(k_ptr->flags, TR_TELEPORT)) break;
3482 o_ptr->name2 = EGO_RING_TELEPORT;
3485 if (o_ptr->to_h) break;
3486 o_ptr->name2 = EGO_RING_TO_H;
3489 if (o_ptr->to_d) break;
3490 o_ptr->name2 = EGO_RING_TO_D;
3493 if ((o_ptr->to_h) || (o_ptr->to_d)) break;
3494 o_ptr->name2 = EGO_RING_SLAY;
3497 if ((have_flag(k_ptr->flags, TR_STR)) || o_ptr->to_h || o_ptr->to_d) break;
3498 o_ptr->name2 = EGO_RING_WIZARD;
3501 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3502 o_ptr->name2 = EGO_RING_HERO;
3505 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3506 if (tmp > 8) o_ptr->name2 = EGO_RING_MANA_BALL;
3507 else if (tmp > 4) o_ptr->name2 = EGO_RING_MANA_BOLT;
3508 else o_ptr->name2 = EGO_RING_MAGIC_MIS;
3511 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3512 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;
3513 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_F;
3514 else if (tmp > 3) o_ptr->name2 = EGO_RING_FIRE_BALL;
3515 else o_ptr->name2 = EGO_RING_FIRE_BOLT;
3518 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3519 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;
3520 if (tmp > 7) o_ptr->name2 = EGO_RING_DRAGON_C;
3521 else if (tmp > 3) o_ptr->name2 = EGO_RING_COLD_BALL;
3522 else o_ptr->name2 = EGO_RING_COLD_BOLT;
3525 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3526 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;
3527 if (tmp > 4) o_ptr->name2 = EGO_RING_ELEC_BALL;
3528 else o_ptr->name2 = EGO_RING_ELEC_BOLT;
3531 if (have_flag(k_ptr->flags, TR_ACTIVATE)) break;
3532 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;
3533 if (tmp > 4) o_ptr->name2 = EGO_RING_ACID_BALL;
3534 else o_ptr->name2 = EGO_RING_ACID_BOLT;
3536 case 21: case 22: case 23: case 24: case 25: case 26:
3537 switch (o_ptr->sval)
3540 if (!one_in_(3)) break;
3541 o_ptr->name2 = EGO_RING_D_SPEED;
3543 case SV_RING_DAMAGE:
3544 case SV_RING_ACCURACY:
3545 case SV_RING_SLAYING:
3546 if (one_in_(2)) break;
3547 if (one_in_(2)) o_ptr->name2 = EGO_RING_HERO;
3550 o_ptr->name2 = EGO_RING_BERSERKER;
3551 o_ptr->to_h -= 2+randint1(4);
3552 o_ptr->to_d += 2+randint1(4);
3555 case SV_RING_PROTECTION:
3556 o_ptr->name2 = EGO_RING_SUPER_AC;
3557 o_ptr->to_a += 7 + m_bonus(5, level);
3559 case SV_RING_RES_FEAR:
3560 o_ptr->name2 = EGO_RING_HERO;
3563 if (one_in_(2)) break;
3564 o_ptr->name2 = EGO_RING_HUNTER;
3566 case SV_RING_SEARCHING:
3567 o_ptr->name2 = EGO_RING_STEALTH;
3569 case SV_RING_TELEPORTATION:
3570 o_ptr->name2 = EGO_RING_TELE_AWAY;
3572 case SV_RING_RES_BLINDNESS:
3574 o_ptr->name2 = EGO_RING_RES_LITE;
3576 o_ptr->name2 = EGO_RING_RES_DARK;
3578 case SV_RING_LORDLY:
3579 if (!one_in_(20)) break;
3580 one_lordly_high_resistance(o_ptr);
3581 one_lordly_high_resistance(o_ptr);
3582 o_ptr->name2 = EGO_RING_TRUE;
3584 case SV_RING_SUSTAIN:
3585 if (!one_in_(4)) break;
3586 o_ptr->name2 = EGO_RING_RES_TIME;
3588 case SV_RING_FLAMES:
3589 if (!one_in_(2)) break;
3590 o_ptr->name2 = EGO_RING_DRAGON_F;
3593 if (!one_in_(2)) break;
3594 o_ptr->name2 = EGO_RING_DRAGON_C;
3596 case SV_RING_WARNING:
3597 if (!one_in_(2)) break;
3598 o_ptr->name2 = EGO_RING_M_DETECT;
3607 o_ptr->curse_flags = 0L;
3609 else if ((power == -2) && one_in_(2))
3611 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3612 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3613 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3614 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3615 o_ptr->art_flags[0] = 0;
3616 o_ptr->art_flags[1] = 0;
3617 while(!o_ptr->name2)
3619 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3623 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3624 o_ptr->name2 = EGO_RING_DRAIN_EXP;
3627 o_ptr->name2 = EGO_RING_NO_MELEE;
3630 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3631 o_ptr->name2 = EGO_RING_AGGRAVATE;
3634 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3635 o_ptr->name2 = EGO_RING_TY_CURSE;
3638 o_ptr->name2 = EGO_RING_ALBINO;
3643 o_ptr->ident |= (IDENT_BROKEN);
3646 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3654 switch (o_ptr->sval)
3656 /* Amulet of wisdom/charisma */
3657 case SV_AMULET_INTELLIGENCE:
3658 case SV_AMULET_WISDOM:
3659 case SV_AMULET_CHARISMA:
3661 o_ptr->pval = 1 + m_bonus(5, level);
3667 o_ptr->ident |= (IDENT_BROKEN);
3670 o_ptr->curse_flags |= (TRC_CURSED);
3672 /* Reverse bonuses */
3673 o_ptr->pval = 0 - o_ptr->pval;
3679 /* Amulet of brilliance */
3680 case SV_AMULET_BRILLIANCE:
3682 o_ptr->pval = 1 + m_bonus(3, level);
3683 if (one_in_(4)) o_ptr->pval++;
3689 o_ptr->ident |= (IDENT_BROKEN);
3692 o_ptr->curse_flags |= (TRC_CURSED);
3694 /* Reverse bonuses */
3695 o_ptr->pval = 0 - o_ptr->pval;
3701 case SV_AMULET_NO_MAGIC: case SV_AMULET_NO_TELE:
3705 o_ptr->curse_flags |= (TRC_CURSED);
3710 case SV_AMULET_RESISTANCE:
3712 if (one_in_(5)) one_high_resistance(o_ptr);
3713 if (one_in_(5)) add_flag(o_ptr->art_flags, TR_RES_POIS);
3717 /* Amulet of searching */
3718 case SV_AMULET_SEARCHING:
3720 o_ptr->pval = randint1(2) + m_bonus(4, level);
3726 o_ptr->ident |= (IDENT_BROKEN);
3729 o_ptr->curse_flags |= (TRC_CURSED);
3731 /* Reverse bonuses */
3732 o_ptr->pval = 0 - (o_ptr->pval);
3738 /* Amulet of the Magi -- never cursed */
3739 case SV_AMULET_THE_MAGI:
3741 o_ptr->pval = randint1(5) + m_bonus(5, level);
3742 o_ptr->to_a = randint1(5) + m_bonus(5, level);
3744 /* gain one low ESP */
3745 add_esp_weak(o_ptr, FALSE);
3747 /* Mention the item */
3748 if (cheat_peek) object_mention(o_ptr);
3753 /* Amulet of Doom -- always cursed */
3754 case SV_AMULET_DOOM:
3757 o_ptr->ident |= (IDENT_BROKEN);
3760 o_ptr->curse_flags |= (TRC_CURSED);
3763 o_ptr->pval = 0 - (randint1(5) + m_bonus(5, level));
3764 o_ptr->to_a = 0 - (randint1(5) + m_bonus(5, level));
3765 if (power > 0) power = 0 - power;
3770 case SV_AMULET_MAGIC_MASTERY:
3772 o_ptr->pval = 1 + m_bonus(4, level);
3778 o_ptr->ident |= (IDENT_BROKEN);
3781 o_ptr->curse_flags |= (TRC_CURSED);
3783 /* Reverse bonuses */
3784 o_ptr->pval = 0 - o_ptr->pval;
3790 if ((one_in_(150) && (power > 0) && !object_is_cursed(o_ptr) && (level > 79))
3791 || (power > 2)) /* power > 2 is debug only */
3793 o_ptr->pval = MIN(o_ptr->pval, 4);
3794 /* Randart amulet */
3795 create_artifact(o_ptr, FALSE);
3797 else if ((power == 2) && one_in_(2))
3799 while(!o_ptr->name2)
3801 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3802 switch(randint1(21))
3805 if (have_flag(k_ptr->flags, TR_SLOW_DIGEST)) break;
3806 o_ptr->name2 = EGO_AMU_SLOW_D;
3809 if (o_ptr->pval) break;
3810 o_ptr->name2 = EGO_AMU_INFRA;
3813 if (have_flag(k_ptr->flags, TR_SEE_INVIS)) break;
3814 o_ptr->name2 = EGO_AMU_SEE_INVIS;
3817 if (have_flag(k_ptr->flags, TR_HOLD_EXP)) break;
3818 o_ptr->name2 = EGO_AMU_HOLD_EXP;
3821 if (have_flag(k_ptr->flags, TR_LEVITATION)) break;
3822 o_ptr->name2 = EGO_AMU_LEVITATION;
3824 case 10: case 11: case 21:
3825 o_ptr->name2 = EGO_AMU_AC;
3828 if (have_flag(k_ptr->flags, TR_RES_FIRE)) break;
3829 if (m_bonus(10, level) > 8)
3830 o_ptr->name2 = EGO_AMU_RES_FIRE_;
3832 o_ptr->name2 = EGO_AMU_RES_FIRE;
3835 if (have_flag(k_ptr->flags, TR_RES_COLD)) break;
3836 if (m_bonus(10, level) > 8)
3837 o_ptr->name2 = EGO_AMU_RES_COLD_;
3839 o_ptr->name2 = EGO_AMU_RES_COLD;
3842 if (have_flag(k_ptr->flags, TR_RES_ELEC)) break;
3843 if (m_bonus(10, level) > 8)
3844 o_ptr->name2 = EGO_AMU_RES_ELEC_;
3846 o_ptr->name2 = EGO_AMU_RES_ELEC;
3849 if (have_flag(k_ptr->flags, TR_RES_ACID)) break;
3850 if (m_bonus(10, level) > 8)
3851 o_ptr->name2 = EGO_AMU_RES_ACID_;
3853 o_ptr->name2 = EGO_AMU_RES_ACID;
3855 case 16: case 17: case 18: case 19: case 20:
3856 switch (o_ptr->sval)
3858 case SV_AMULET_TELEPORT:
3859 if (m_bonus(10, level) > 9) o_ptr->name2 = EGO_AMU_D_DOOR;
3860 else if (one_in_(2)) o_ptr->name2 = EGO_AMU_JUMP;
3861 else o_ptr->name2 = EGO_AMU_TELEPORT;
3863 case SV_AMULET_RESIST_ACID:
3864 if ((m_bonus(10, level) > 6) && one_in_(2)) o_ptr->name2 = EGO_AMU_RES_ACID_;
3866 case SV_AMULET_SEARCHING:
3867 o_ptr->name2 = EGO_AMU_STEALTH;
3869 case SV_AMULET_BRILLIANCE:
3870 if (!one_in_(3)) break;
3871 o_ptr->name2 = EGO_AMU_IDENT;
3873 case SV_AMULET_CHARISMA:
3874 if (!one_in_(3)) break;
3875 o_ptr->name2 = EGO_AMU_CHARM;
3877 case SV_AMULET_THE_MAGI:
3878 if (one_in_(2)) break;
3879 o_ptr->name2 = EGO_AMU_GREAT;
3881 case SV_AMULET_RESISTANCE:
3882 if (!one_in_(5)) break;
3883 o_ptr->name2 = EGO_AMU_DEFENDER;
3885 case SV_AMULET_TELEPATHY:
3886 if (!one_in_(3)) break;
3887 o_ptr->name2 = EGO_AMU_DETECTION;
3893 o_ptr->curse_flags = 0L;
3895 else if ((power == -2) && one_in_(2))
3897 if (o_ptr->to_h > 0) o_ptr->to_h = 0-o_ptr->to_h;
3898 if (o_ptr->to_d > 0) o_ptr->to_d = 0-o_ptr->to_d;
3899 if (o_ptr->to_a > 0) o_ptr->to_a = 0-o_ptr->to_a;
3900 if (o_ptr->pval > 0) o_ptr->pval = 0-o_ptr->pval;
3901 o_ptr->art_flags[0] = 0;
3902 o_ptr->art_flags[1] = 0;
3903 while(!o_ptr->name2)
3905 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3909 if (have_flag(k_ptr->flags, TR_DRAIN_EXP)) break;
3910 o_ptr->name2 = EGO_AMU_DRAIN_EXP;
3913 o_ptr->name2 = EGO_AMU_FOOL;
3916 if (have_flag(k_ptr->flags, TR_AGGRAVATE)) break;
3917 o_ptr->name2 = EGO_AMU_AGGRAVATE;
3920 if (have_flag(k_ptr->flags, TR_TY_CURSE)) break;
3921 o_ptr->name2 = EGO_AMU_TY_CURSE;
3924 o_ptr->name2 = EGO_AMU_NAIVETY;
3929 o_ptr->ident |= (IDENT_BROKEN);
3932 o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
3940 * @brief モンスターが人形のベースにできるかを返す
3941 * @param r_idx チェックしたいモンスター種族のID
3942 * @return 人形にできるならTRUEを返す
3944 static bool item_monster_okay(int r_idx)
3946 monster_race *r_ptr = &r_info[r_idx];
3949 if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3950 if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
3951 if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
3952 if (r_ptr->flags7 & RF7_NAZGUL) return (FALSE);
3953 if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
3954 if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
3962 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
3963 * Apply magic to an item known to be "boring"
3964 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
3965 * @param level 生成基準階
3966 * @param power 生成ランク
3969 * Hack -- note the special code for various items
3971 static void a_m_aux_4(object_type *o_ptr, int level, int power)
3973 object_kind *k_ptr = &k_info[o_ptr->k_idx];
3978 /* Apply magic (good or bad) according to type */
3979 switch (o_ptr->tval)
3988 o_ptr->ident |= (IDENT_BROKEN);
3991 o_ptr->curse_flags |= (TRC_CURSED);
3998 o_ptr->xtra4 = o_ptr->pval;
4004 /* Hack -- Torches -- random fuel */
4005 if (o_ptr->sval == SV_LITE_TORCH)
4007 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4011 /* Hack -- Lanterns -- random fuel */
4012 if (o_ptr->sval == SV_LITE_LANTERN)
4014 if (o_ptr->pval > 0) o_ptr->xtra4 = randint1(o_ptr->pval);
4018 if (power > 2) /* power > 2 is debug only */
4020 create_artifact(o_ptr, FALSE);
4022 else if ((power == 2) || ((power == 1) && one_in_(3)))
4024 while (!o_ptr->name2)
4028 bool okay_flag = TRUE;
4030 o_ptr->name2 = get_random_ego(INVEN_LITE, TRUE);
4032 switch (o_ptr->name2)
4035 if (o_ptr->sval == SV_LITE_FEANOR)
4043 else if (power == -2)
4045 o_ptr->name2 = get_random_ego(INVEN_LITE, FALSE);
4047 switch (o_ptr->name2)
4049 case EGO_LITE_DARKNESS:
4052 if (o_ptr->sval == SV_LITE_TORCH)
4054 add_flag(o_ptr->art_flags, TR_LITE_M1);
4056 else if (o_ptr->sval == SV_LITE_LANTERN)
4058 add_flag(o_ptr->art_flags, TR_LITE_M2);
4060 else if (o_ptr->sval == SV_LITE_FEANOR)
4062 add_flag(o_ptr->art_flags, TR_LITE_M3);
4074 /* The wand or staff gets a number of initial charges equal
4075 * to between 1/2 (+1) and the full object kind's pval. -LM-
4077 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
4083 /* Transfer the pval. -LM- */
4084 o_ptr->pval = k_ptr->pval;
4091 object_aware(o_ptr);
4092 object_known(o_ptr);
4101 monster_race *r_ptr;
4103 /* Pick a random non-unique monster race */
4106 i = randint1(max_r_idx - 1);
4108 if (!item_monster_okay(i)) continue;
4109 if (i == MON_TSUCHINOKO) continue;
4113 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4115 /* Ignore dead monsters */
4116 if (!r_ptr->rarity) continue;
4118 /* Ignore uncommon monsters */
4119 if (r_ptr->rarity > 100) continue;
4121 /* Prefer less out-of-depth monsters */
4122 if (randint0(check)) continue;
4129 /* Some figurines are cursed */
4130 if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
4134 msg_format(_("%sの人形, 深さ +%d%s", "Figurine of %s, depth +%d%s"),
4135 r_name + r_ptr->name, check - 1,
4136 !object_is_cursed(o_ptr) ? "" : " {cursed}");
4149 monster_race *r_ptr;
4151 if (o_ptr->sval == SV_SKELETON)
4153 match = RF9_DROP_SKELETON;
4155 else if (o_ptr->sval == SV_CORPSE)
4157 match = RF9_DROP_CORPSE;
4160 /* Hack -- Remove the monster restriction */
4161 get_mon_num_prep(item_monster_okay, NULL);
4163 /* Pick a random non-unique monster race */
4166 i = get_mon_num(dun_level);
4170 check = (dun_level < r_ptr->level) ? (r_ptr->level - dun_level) : 0;
4172 /* Ignore dead monsters */
4173 if (!r_ptr->rarity) continue;
4175 /* Ignore corpseless monsters */
4176 if (!(r_ptr->flags9 & match)) continue;
4178 /* Prefer less out-of-depth monsters */
4179 if (randint0(check)) continue;
4188 msg_format(_("%sの死体, 深さ +%d", "Corpse of %s, depth +%d"),
4189 r_name + r_ptr->name, check - 1);
4192 object_aware(o_ptr);
4193 object_known(o_ptr);
4201 monster_race *r_ptr;
4203 /* Pick a random monster race */
4206 i = randint1(max_r_idx - 1);
4210 /* Ignore dead monsters */
4211 if (!r_ptr->rarity) continue;
4220 msg_format(_("%sの像", "Statue of %s"), r_name + r_ptr->name);
4222 object_aware(o_ptr);
4223 object_known(o_ptr);
4230 byte obj_level = k_info[o_ptr->k_idx].level;
4232 /* Hack -- skip ruined chests */
4233 if (obj_level <= 0) break;
4235 /* Hack -- pick a "difficulty" */
4236 o_ptr->pval = randint1(obj_level);
4237 if (o_ptr->sval == SV_CHEST_KANDUME) o_ptr->pval = 6;
4239 o_ptr->xtra3 = dun_level + 5;
4241 /* Never exceed "difficulty" of 55 to 59 */
4242 if (o_ptr->pval > 55) o_ptr->pval = 55 + (byte)randint0(5);
4250 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
4251 * Complete the "creation" of an object by applying "magic" to the item
4252 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
4254 * @param mode 生成オプション
4257 * This includes not only rolling for random bonuses, but also putting the\n
4258 * finishing touches on ego-items and artifacts, giving charges to wands and\n
4259 * staffs, giving fuel to lites, and placing traps on chests.\n
4261 * In particular, note that "Instant Artifacts", if "created" by an external\n
4262 * routine, must pass through this function to complete the actual creation.\n
4264 * The base "chance" of the item being "good" increases with the "level"\n
4265 * parameter, which is usually derived from the dungeon level, being equal\n
4266 * to the level plus 10, up to a maximum of 75. If "good" is true, then\n
4267 * the object is guaranteed to be "good". If an object is "good", then\n
4268 * the chance that the object will be "great" (ego-item or artifact), also\n
4269 * increases with the "level", being equal to half the level, plus 5, up to\n
4270 * a maximum of 20. If "great" is true, then the object is guaranteed to be\n
4271 * "great". At dungeon level 65 and below, 15/100 objects are "great".\n
4273 * If the object is not "good", there is a chance it will be "cursed", and\n
4274 * if it is "cursed", there is a chance it will be "broken". These chances\n
4275 * are related to the "good" / "great" chances above.\n
4277 * Otherwise "normal" rings and amulets will be "good" half the time and\n
4278 * "cursed" half the time, unless the ring/amulet is always good or cursed.\n
4280 * If "okay" is true, and the object is going to be "great", then there is\n
4281 * a chance that an artifact will be created. This is true even if both the\n
4282 * "good" and "great" arguments are false. As a total hack, if "great" is\n
4283 * true, then the item gets 3 extra "attempts" to become an artifact.\n
4285 void apply_magic(object_type *o_ptr, int lev, u32b mode)
4287 int i, rolls, f1, f2, power;
4289 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) lev += randint0(p_ptr->lev/2+10);
4291 /* Maximum "level" for various things */
4292 if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
4294 /* Base chance of being "good" */
4297 /* Maximal chance of being "good" */
4298 if (f1 > d_info[dungeon_type].obj_good) f1 = d_info[dungeon_type].obj_good;
4300 /* Base chance of being "great" */
4303 /* Maximal chance of being "great" */
4304 if ((p_ptr->pseikaku != SEIKAKU_MUNCHKIN) && (f2 > d_info[dungeon_type].obj_great))
4305 f2 = d_info[dungeon_type].obj_great;
4307 if (p_ptr->muta3 & MUT3_GOOD_LUCK)
4312 else if(p_ptr->muta3 & MUT3_BAD_LUCK)
4321 /* Roll for "good" */
4322 if ((mode & AM_GOOD) || magik(f1))
4327 /* Roll for "great" */
4328 if ((mode & AM_GREAT) || magik(f2))
4332 /* Roll for "special" */
4333 if (mode & AM_SPECIAL) power = 3;
4337 /* Roll for "cursed" */
4340 /* Assume "cursed" */
4343 /* Roll for "broken" */
4344 if (magik(f2)) power = -2;
4348 if (mode & AM_CURSED)
4350 /* Assume 'cursed' */
4355 /* Everything else gets more badly cursed */
4362 /* Assume no rolls */
4365 /* Get one roll if excellent */
4366 if (power >= 2) rolls = 1;
4368 /* Hack -- Get four rolls if forced great or special */
4369 if (mode & (AM_GREAT | AM_SPECIAL)) rolls = 4;
4371 /* Hack -- Get no rolls if not allowed */
4372 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1) rolls = 0;
4374 /* Roll for artifacts if allowed */
4375 for (i = 0; i < rolls; i++)
4377 /* Roll for an artifact */
4378 if (make_artifact(o_ptr)) break;
4379 if ((p_ptr->muta3 & MUT3_GOOD_LUCK) && one_in_(77))
4381 if (make_artifact(o_ptr)) break;
4386 /* Hack -- analyze artifacts */
4387 if (object_is_fixed_artifact(o_ptr))
4389 artifact_type *a_ptr = &a_info[o_ptr->name1];
4391 /* Hack -- Mark the artifact as "created" */
4394 /* Hack -- Memorize location of artifact in saved floors */
4395 if (character_dungeon)
4396 a_ptr->floor_id = p_ptr->floor_id;
4398 /* Extract the other fields */
4399 o_ptr->pval = a_ptr->pval;
4400 o_ptr->ac = a_ptr->ac;
4401 o_ptr->dd = a_ptr->dd;
4402 o_ptr->ds = a_ptr->ds;
4403 o_ptr->to_a = a_ptr->to_a;
4404 o_ptr->to_h = a_ptr->to_h;
4405 o_ptr->to_d = a_ptr->to_d;
4406 o_ptr->weight = a_ptr->weight;
4407 o_ptr->xtra2 = a_ptr->act_idx;
4409 if (o_ptr->name1 == ART_MILIM)
4411 if(p_ptr->pseikaku == SEIKAKU_SEXY)
4417 /* Hack -- extract the "broken" flag */
4418 if (!a_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4420 /* Hack -- extract the "cursed" flag */
4421 if (a_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4422 if (a_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4423 if (a_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4424 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4425 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4426 if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4429 /* Cheat -- peek at the item */
4430 if (cheat_peek) object_mention(o_ptr);
4438 switch (o_ptr->tval)
4447 if (power) a_m_aux_1(o_ptr, lev, power);
4453 if (power && !(o_ptr->sval == SV_DEATH_SCYTHE)) a_m_aux_1(o_ptr, lev, power);
4459 if (power && !(o_ptr->sval == SV_DOKUBARI)) a_m_aux_1(o_ptr, lev, power);
4473 /* Elven Cloak and Black Clothes ... */
4474 if (((o_ptr->tval == TV_CLOAK) && (o_ptr->sval == SV_ELVEN_CLOAK)) ||
4475 ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_KUROSHOUZOKU)))
4476 o_ptr->pval = randint1(4);
4480 ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
4481 ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
4482 ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
4483 ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)))
4484 a_m_aux_2(o_ptr, lev, power);
4486 if (power) a_m_aux_2(o_ptr, lev, power);
4494 if (!power && (randint0(100) < 50)) power = -1;
4495 a_m_aux_3(o_ptr, lev, power);
4501 a_m_aux_4(o_ptr, lev, power);
4506 if ((o_ptr->tval == TV_SOFT_ARMOR) &&
4507 (o_ptr->sval == SV_ABUNAI_MIZUGI) &&
4508 (p_ptr->pseikaku == SEIKAKU_SEXY))
4511 add_flag(o_ptr->art_flags, TR_STR);
4512 add_flag(o_ptr->art_flags, TR_INT);
4513 add_flag(o_ptr->art_flags, TR_WIS);
4514 add_flag(o_ptr->art_flags, TR_DEX);
4515 add_flag(o_ptr->art_flags, TR_CON);
4516 add_flag(o_ptr->art_flags, TR_CHR);
4519 /* Hack -- analyze ego-items */
4520 if (object_is_ego(o_ptr))
4522 ego_item_type *e_ptr = &e_info[o_ptr->name2];
4524 /* Hack -- acquire "broken" flag */
4525 if (!e_ptr->cost) o_ptr->ident |= (IDENT_BROKEN);
4527 /* Hack -- acquire "cursed" flag */
4528 if (e_ptr->gen_flags & TRG_CURSED) o_ptr->curse_flags |= (TRC_CURSED);
4529 if (e_ptr->gen_flags & TRG_HEAVY_CURSE) o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
4530 if (e_ptr->gen_flags & TRG_PERMA_CURSE) o_ptr->curse_flags |= (TRC_PERMA_CURSE);
4531 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4532 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4533 if (e_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4535 if (e_ptr->gen_flags & (TRG_ONE_SUSTAIN)) one_sustain(o_ptr);
4536 if (e_ptr->gen_flags & (TRG_XTRA_POWER)) one_ability(o_ptr);
4537 if (e_ptr->gen_flags & (TRG_XTRA_H_RES)) one_high_resistance(o_ptr);
4538 if (e_ptr->gen_flags & (TRG_XTRA_E_RES)) one_ele_resistance(o_ptr);
4539 if (e_ptr->gen_flags & (TRG_XTRA_D_RES)) one_dragon_ele_resistance(o_ptr);
4540 if (e_ptr->gen_flags & (TRG_XTRA_L_RES)) one_lordly_high_resistance(o_ptr);
4541 if (e_ptr->gen_flags & (TRG_XTRA_RES)) one_resistance(o_ptr);
4542 if (e_ptr->gen_flags & (TRG_XTRA_DICE))
4548 while (one_in_(o_ptr->dd));
4550 if (o_ptr->dd > 9) o_ptr->dd = 9;
4553 /* Hack -- apply activatin index if needed */
4554 if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
4556 /* Hack -- apply extra penalties if needed */
4557 if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
4559 /* Hack -- obtain bonuses */
4560 if (e_ptr->max_to_h) o_ptr->to_h -= randint1(e_ptr->max_to_h);
4561 if (e_ptr->max_to_d) o_ptr->to_d -= randint1(e_ptr->max_to_d);
4562 if (e_ptr->max_to_a) o_ptr->to_a -= randint1(e_ptr->max_to_a);
4564 /* Hack -- obtain pval */
4565 if (e_ptr->max_pval) o_ptr->pval -= randint1(e_ptr->max_pval);
4568 /* Hack -- apply extra bonuses if needed */
4571 /* Hack -- obtain bonuses */
4572 if (e_ptr->max_to_h)
4574 if (e_ptr->max_to_h > 127)
4575 o_ptr->to_h -= randint1(256-e_ptr->max_to_h);
4576 else o_ptr->to_h += randint1(e_ptr->max_to_h);
4578 if (e_ptr->max_to_d)
4580 if (e_ptr->max_to_d > 127)
4581 o_ptr->to_d -= randint1(256-e_ptr->max_to_d);
4582 else o_ptr->to_d += randint1(e_ptr->max_to_d);
4584 if (e_ptr->max_to_a)
4586 if (e_ptr->max_to_a > 127)
4587 o_ptr->to_a -= randint1(256-e_ptr->max_to_a);
4588 else o_ptr->to_a += randint1(e_ptr->max_to_a);
4591 /* Accuracy ego must have high to_h */
4592 if(o_ptr->name2 == EGO_ACCURACY)
4594 while(o_ptr->to_h < o_ptr->to_d + 10)
4599 o_ptr->to_h = MAX(o_ptr->to_h, 15);
4602 /* Accuracy ego must have high to_h */
4603 if(o_ptr->name2 == EGO_VELOCITY)
4605 while(o_ptr->to_d < o_ptr->to_h + 10)
4610 o_ptr->to_d = MAX(o_ptr->to_d, 15);
4613 /* Protection ego must have high to_a */
4614 if((o_ptr->name2 == EGO_PROTECTION) || (o_ptr->name2 == EGO_S_PROTECTION) || (o_ptr->name2 == EGO_H_PROTECTION))
4616 o_ptr->to_a = MAX(o_ptr->to_a, 15);
4619 /* Hack -- obtain pval */
4620 if (e_ptr->max_pval)
4622 if ((o_ptr->name2 == EGO_HA) && (have_flag(o_ptr->art_flags, TR_BLOWS)))
4625 if ((lev > 60) && one_in_(3) && ((o_ptr->dd*(o_ptr->ds+1)) < 15)) o_ptr->pval++;
4627 else if (o_ptr->name2 == EGO_DEMON)
4629 if(have_flag(o_ptr->art_flags, TR_BLOWS))
4631 o_ptr->pval += randint1(2);
4635 o_ptr->pval += randint1(e_ptr->max_pval);
4638 else if (o_ptr->name2 == EGO_ATTACKS)
4640 o_ptr->pval = randint1(e_ptr->max_pval*lev/100+1);
4641 if (o_ptr->pval > 3) o_ptr->pval = 3;
4642 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA))
4643 o_ptr->pval += randint1(2);
4645 else if (o_ptr->name2 == EGO_BAT)
4647 o_ptr->pval = randint1(e_ptr->max_pval);
4648 if (o_ptr->sval == SV_ELVEN_CLOAK) o_ptr->pval += randint1(2);
4650 else if (o_ptr->name2 == EGO_A_DEMON || o_ptr->name2 == EGO_DRUID || o_ptr->name2 == EGO_OLOG)
4652 o_ptr->pval = randint1(e_ptr->max_pval);
4656 o_ptr->pval += randint1(e_ptr->max_pval);
4661 if ((o_ptr->name2 == EGO_SPEED) && (lev < 50))
4663 o_ptr->pval = randint1(o_ptr->pval);
4665 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
4669 /* Cheat -- describe the item */
4670 if (cheat_peek) object_mention(o_ptr);
4676 /* Examine real objects */
4679 object_kind *k_ptr = &k_info[o_ptr->k_idx];
4681 /* Hack -- acquire "broken" flag */
4682 if (!k_info[o_ptr->k_idx].cost) o_ptr->ident |= (IDENT_BROKEN);
4684 /* Hack -- acquire "cursed" flag */
4685 if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED);
4686 if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= TRC_HEAVY_CURSE;
4687 if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= TRC_PERMA_CURSE;
4688 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr);
4689 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
4690 if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
4696 * @brief ベースアイテムが上質として扱われるかどうかを返す。
4697 * Hack -- determine if a template is "good"
4698 * @param k_idx 判定したいベースアイテムのID
4699 * @return ベースアイテムが上質ならばTRUEを返す。
4701 static bool kind_is_good(int k_idx)
4703 object_kind *k_ptr = &k_info[k_idx];
4705 /* Analyze the item type */
4706 switch (k_ptr->tval)
4708 /* Armor -- Good unless damaged */
4719 if (k_ptr->to_a < 0) return (FALSE);
4723 /* Weapons -- Good unless damaged */
4730 if (k_ptr->to_h < 0) return (FALSE);
4731 if (k_ptr->to_d < 0) return (FALSE);
4735 /* Ammo -- Arrows/Bolts are good */
4742 /* Books -- High level books are good (except Arcane books) */
4744 case TV_SORCERY_BOOK:
4745 case TV_NATURE_BOOK:
4750 case TV_DAEMON_BOOK:
4751 case TV_CRUSADE_BOOK:
4753 case TV_HISSATSU_BOOK:
4756 if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4760 /* Rings -- Rings of Speed are good */
4763 if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4764 if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4768 /* Amulets -- Amulets of the Magi and Resistance are good */
4771 if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4772 if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4777 /* Assume not good */
4782 * @brief 生成階に応じたベースアイテムの生成を行う。
4783 * Attempt to make an object (normal or good/great)
4784 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4785 * @param mode オプションフラグ
4786 * @return 生成に成功したらTRUEを返す。
4788 * This routine plays nasty games to generate the "special artifacts".\n
4789 * This routine uses "object_level" for the "generation level".\n
4790 * We assume that the given object has been "wiped".\n
4792 bool make_object(object_type *j_ptr, u32b mode)
4798 /* Chance of "special object" */
4799 prob = ((mode & AM_GOOD) ? 10 : 1000);
4801 /* Base level for the object */
4802 base = ((mode & AM_GOOD) ? (object_level + 10) : object_level);
4805 /* Generate a special object, or a normal object */
4806 if (!one_in_(prob) || !make_artifact_special(j_ptr))
4811 if ((mode & AM_GOOD) && !get_obj_num_hook)
4813 /* Activate restriction (if already specified, use that) */
4814 get_obj_num_hook = kind_is_good;
4817 /* Restricted objects - prepare allocation table */
4818 if (get_obj_num_hook) get_obj_num_prep();
4820 /* Pick a random object */
4821 k_idx = get_obj_num(base);
4823 /* Restricted objects */
4824 if (get_obj_num_hook)
4826 /* Clear restriction */
4827 get_obj_num_hook = NULL;
4829 /* Reset allocation table to default */
4833 /* Handle failure */
4834 if (!k_idx) return (FALSE);
4836 /* Prepare the object */
4837 object_prep(j_ptr, k_idx);
4840 /* Apply magic (allow artifacts) */
4841 apply_magic(j_ptr, object_level, mode);
4843 /* Hack -- generate multiple spikes/missiles */
4844 switch (j_ptr->tval)
4852 j_ptr->number = (byte)damroll(6, 7);
4856 obj_level = k_info[j_ptr->k_idx].level;
4857 if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
4859 /* Notice "okay" out-of-depth objects */
4860 if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
4861 (obj_level > dun_level))
4863 /* Cheat -- peek at items */
4864 if (cheat_peek) object_mention(j_ptr);
4873 * @brief フロアの指定位置に生成階に応じたベースアイテムの生成を行う。
4874 * Attempt to place an object (normal or good/great) at the given location.
4875 * @param y 配置したいフロアのY座標
4876 * @param x 配置したいフロアのX座標
4877 * @param mode オプションフラグ
4878 * @return 生成に成功したらTRUEを返す。
4880 * This routine plays nasty games to generate the "special artifacts".\n
4881 * This routine uses "object_level" for the "generation level".\n
4882 * This routine requires a clean floor grid destination.\n
4884 void place_object(int y, int x, u32b mode)
4889 cave_type *c_ptr = &cave[y][x];
4895 /* Paranoia -- check bounds */
4896 if (!in_bounds(y, x)) return;
4898 /* Require floor space */
4899 if (!cave_drop_bold(y, x)) return;
4901 /* Avoid stacking on other objects */
4902 if (c_ptr->o_idx) return;
4905 /* Get local object */
4908 /* Wipe the object */
4911 /* Make an object (if possible) */
4912 if (!make_object(q_ptr, mode)) return;
4915 /* Make an object */
4923 /* Acquire object */
4924 o_ptr = &o_list[o_idx];
4926 /* Structure Copy */
4927 object_copy(o_ptr, q_ptr);
4934 o_ptr->next_o_idx = c_ptr->o_idx;
4936 /* Place the object */
4937 c_ptr->o_idx = o_idx;
4947 /* Hack -- Preserve artifacts */
4948 if (object_is_fixed_artifact(q_ptr))
4950 a_info[q_ptr->name1].cur_num = 0;
4957 * @brief 生成階に応じた財宝オブジェクトの生成を行う。
4958 * Make a treasure object
4959 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
4960 * @return 生成に成功したらTRUEを返す。
4962 * The location must be a legal, clean, floor grid.
4964 bool make_gold(object_type *j_ptr)
4971 /* Hack -- Pick a Treasure variety */
4972 i = ((randint1(object_level + 2) + 2) / 2) - 1;
4974 /* Apply "extra" magic */
4975 if (one_in_(GREAT_OBJ))
4977 i += randint1(object_level + 1);
4980 /* Hack -- Creeping Coins only generate "themselves" */
4981 if (coin_type) i = coin_type;
4983 /* Do not create "illegal" Treasure Types */
4984 if (i >= MAX_GOLD) i = MAX_GOLD - 1;
4986 /* Prepare a gold object */
4987 object_prep(j_ptr, OBJ_GOLD_LIST + i);
4989 /* Hack -- Base coin cost */
4990 base = k_info[OBJ_GOLD_LIST+i].cost;
4992 /* Determine how much the treasure is "worth" */
4993 j_ptr->pval = (base + (8L * randint1(base)) + randint1(8));
5001 * @brief フロアの指定位置に生成階に応じた財宝オブジェクトの生成を行う。
5002 * Places a treasure (Gold or Gems) at given location
5003 * @param y 配置したいフロアのY座標
5004 * @param x 配置したいフロアのX座標
5005 * @return 生成に成功したらTRUEを返す。
5007 * The location must be a legal, clean, floor grid.
5009 void place_gold(int y, int x)
5014 cave_type *c_ptr = &cave[y][x];
5021 /* Paranoia -- check bounds */
5022 if (!in_bounds(y, x)) return;
5024 /* Require floor space */
5025 if (!cave_drop_bold(y, x)) return;
5027 /* Avoid stacking on other objects */
5028 if (c_ptr->o_idx) return;
5031 /* Get local object */
5034 /* Wipe the object */
5037 /* Make some gold */
5038 if (!make_gold(q_ptr)) return;
5041 /* Make an object */
5049 /* Acquire object */
5050 o_ptr = &o_list[o_idx];
5052 /* Copy the object */
5053 object_copy(o_ptr, q_ptr);
5060 o_ptr->next_o_idx = c_ptr->o_idx;
5062 /* Place the object */
5063 c_ptr->o_idx = o_idx;
5075 * @brief 生成済のオブジェクトをフロアの所定の位置に落とす。
5076 * Let an object fall to the ground at or near a location.
5077 * @param j_ptr 落としたいオブジェクト構造体の参照ポインタ
5078 * @param chance ドロップの成功率(%)
5079 * @param y 配置したいフロアのY座標
5080 * @param x 配置したいフロアのX座標
5081 * @return 生成に成功したらTRUEを返す。
5083 * The initial location is assumed to be "in_bounds()".\n
5085 * This function takes a parameter "chance". This is the percentage\n
5086 * chance that the item will "disappear" instead of drop. If the object\n
5087 * has been thrown, then this is the chance of disappearance on contact.\n
5089 * Hack -- this function uses "chance" to determine if it should produce\n
5090 * some form of "description" of the drop event (under the player).\n
5092 * We check several locations to see if we can find a location at which\n
5093 * the object can combine, stack, or be placed. Artifacts will try very\n
5094 * hard to be placed, including "teleporting" to a useful grid if needed.\n
5096 s16b drop_near(object_type *j_ptr, int chance, int y, int x)
5107 s16b this_o_idx, next_o_idx = 0;
5111 char o_name[MAX_NLEN];
5117 /* Extract plural */
5118 bool plural = (j_ptr->number != 1);
5121 /* Describe object */
5122 object_desc(o_name, j_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5125 /* Handle normal "breakage" */
5126 if (!object_is_artifact(j_ptr) && (randint0(100) < chance))
5130 msg_format("%sは消えた。", o_name);
5132 msg_format("The %s disappear%s.",
5133 o_name, (plural ? "" : "s"));
5138 if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)"));
5155 /* Scan local grids */
5156 for (dy = -3; dy <= 3; dy++)
5158 /* Scan local grids */
5159 for (dx = -3; dx <= 3; dx++)
5163 /* Calculate actual distance */
5164 d = (dy * dy) + (dx * dx);
5166 /* Ignore distant grids */
5167 if (d > 10) continue;
5173 /* Skip illegal grids */
5174 if (!in_bounds(ty, tx)) continue;
5176 /* Require line of projection */
5177 if (!projectable(y, x, ty, tx)) continue;
5180 c_ptr = &cave[ty][tx];
5182 /* Require floor space */
5183 if (!cave_drop_bold(ty, tx)) continue;
5188 /* Scan objects in that grid */
5189 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5193 /* Acquire object */
5194 o_ptr = &o_list[this_o_idx];
5196 /* Acquire next object */
5197 next_o_idx = o_ptr->next_o_idx;
5199 /* Check for possible combination */
5200 if (object_similar(o_ptr, j_ptr)) comb = TRUE;
5206 /* Add new object */
5210 if (k > 99) continue;
5212 /* Calculate score */
5213 s = 1000 - (d + k * 5);
5215 /* Skip bad values */
5216 if (s < bs) continue;
5218 /* New best value */
5221 /* Apply the randomizer to equivalent values */
5222 if ((++bn >= 2) && !one_in_(bn)) continue;
5237 /* Handle lack of space */
5238 if (!flag && !object_is_artifact(j_ptr))
5242 msg_format("%sは消えた。", o_name);
5244 msg_format("The %s disappear%s.",
5245 o_name, (plural ? "" : "s"));
5250 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5258 for (i = 0; !flag && (i < 1000); i++)
5261 ty = rand_spread(by, 1);
5262 tx = rand_spread(bx, 1);
5264 /* Verify location */
5265 if (!in_bounds(ty, tx)) continue;
5267 /* Bounce to that location */
5271 /* Require floor space */
5272 if (!cave_drop_bold(by, bx)) continue;
5281 int candidates = 0, pick;
5283 for (ty = 1; ty < cur_hgt - 1; ty++)
5285 for (tx = 1; tx < cur_wid - 1; tx++)
5287 /* A valid space found */
5288 if (cave_drop_bold(ty, tx)) candidates++;
5292 /* No valid place! */
5297 msg_format("%sは消えた。", o_name);
5299 msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
5303 if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)"));
5305 /* Mega-Hack -- preserve artifacts */
5308 /* Hack -- Preserve unknown artifacts */
5309 if (object_is_fixed_artifact(j_ptr) && !object_is_known(j_ptr))
5311 /* Mega-Hack -- Preserve the artifact */
5312 a_info[j_ptr->name1].cur_num = 0;
5320 /* Choose a random one */
5321 pick = randint1(candidates);
5323 for (ty = 1; ty < cur_hgt - 1; ty++)
5325 for (tx = 1; tx < cur_wid - 1; tx++)
5327 if (cave_drop_bold(ty, tx))
5331 /* Is this a picked one? */
5345 c_ptr = &cave[by][bx];
5347 /* Scan objects in that grid for combination */
5348 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5352 /* Acquire object */
5353 o_ptr = &o_list[this_o_idx];
5355 /* Acquire next object */
5356 next_o_idx = o_ptr->next_o_idx;
5358 /* Check for combination */
5359 if (object_similar(o_ptr, j_ptr))
5361 /* Combine the items */
5362 object_absorb(o_ptr, j_ptr);
5372 /* Get new object */
5373 if (!done) o_idx = o_pop();
5376 if (!done && !o_idx)
5380 msg_format("%sは消えた。", o_name);
5382 msg_format("The %s disappear%s.",
5383 o_name, (plural ? "" : "s"));
5388 if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
5390 /* Hack -- Preserve artifacts */
5391 if (object_is_fixed_artifact(j_ptr))
5393 a_info[j_ptr->name1].cur_num = 0;
5403 /* Structure copy */
5404 object_copy(&o_list[o_idx], j_ptr);
5406 /* Access new object */
5407 j_ptr = &o_list[o_idx];
5414 j_ptr->held_m_idx = 0;
5417 j_ptr->next_o_idx = c_ptr->o_idx;
5419 /* Place the object */
5420 c_ptr->o_idx = o_idx;
5435 /* Mega-Hack -- no message if "dropped" by player */
5436 /* Message when an object falls under the player */
5437 if (chance && player_bold(by, bx))
5439 msg_print(_("何かが足下に転がってきた。", "You feel something roll beneath your feet."));
5451 * Scatter some "great" objects near the player
5452 * @param y1 配置したいフロアのY座標
5453 * @param x1 配置したいフロアのX座標
5454 * @param num 獲得の処理回数
5455 * @param great TRUEならば必ず高級品以上を落とす
5456 * @param special TRUEならば必ず特別品を落とす
5457 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5460 void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
5463 object_type object_type_body;
5464 u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
5469 /* Get local object */
5470 i_ptr = &object_type_body;
5472 /* Wipe the object */
5475 /* Make a good (or great) object (if possible) */
5476 if (!make_object(i_ptr, mode)) continue;
5480 object_aware(i_ptr);
5481 object_known(i_ptr);
5484 /* Drop the object */
5485 (void)drop_near(i_ptr, -1, y1, x1);
5490 * Scatter some "amusing" objects near the player
5493 #define AMS_NOTHING 0x00 /* No restriction */
5494 #define AMS_NO_UNIQUE 0x01 /* Don't make the amusing object of uniques */
5495 #define AMS_FIXED_ART 0x02 /* Make a fixed artifact based on the amusing object */
5496 #define AMS_MULTIPLE 0x04 /* Drop 1-3 objects for one type */
5497 #define AMS_PILE 0x08 /* Drop 1-99 pile objects for one type */
5507 amuse_type amuse_info[] =
5509 { TV_BOTTLE, SV_ANY, 5, AMS_NOTHING },
5510 { TV_JUNK, SV_ANY, 3, AMS_MULTIPLE },
5511 { TV_SPIKE, SV_ANY, 10, AMS_PILE },
5512 { TV_STATUE, SV_ANY, 15, AMS_NOTHING },
5513 { TV_CORPSE, SV_ANY, 15, AMS_NO_UNIQUE },
5514 { TV_SKELETON, SV_ANY, 10, AMS_NO_UNIQUE },
5515 { TV_FIGURINE, SV_ANY, 10, AMS_NO_UNIQUE },
5516 { TV_PARCHMENT, SV_ANY, 1, AMS_NOTHING },
5517 { TV_POLEARM, SV_TSURIZAO, 3, AMS_NOTHING }, //Fishing Pole of Taikobo
5518 { TV_SWORD, SV_BROKEN_DAGGER, 3, AMS_FIXED_ART }, //Broken Dagger of Magician
5519 { TV_SWORD, SV_BROKEN_DAGGER, 10, AMS_NOTHING },
5520 { TV_SWORD, SV_BROKEN_SWORD, 5, AMS_NOTHING },
5521 { TV_SCROLL, SV_SCROLL_AMUSEMENT, 10, AMS_NOTHING },
5528 * @param y1 配置したいフロアのY座標
5529 * @param x1 配置したいフロアのX座標
5530 * @param num 誰得の処理回数
5531 * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
5534 void amusement(int y1, int x1, int num, bool known)
5537 object_type object_type_body;
5540 for (n = 0; amuse_info[n].tval != 0; n++)
5542 t += amuse_info[n].prob;
5548 int i, k_idx, a_idx = 0;
5549 int r = randint0(t);
5550 bool insta_art, fixed_art;
5554 r -= amuse_info[i].prob;
5558 /* Get local object */
5559 i_ptr = &object_type_body;
5561 /* Wipe the object */
5564 /* Wipe the object */
5565 k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
5567 /* Paranoia - reroll if nothing */
5568 if (!k_idx) continue;
5570 /* Search an artifact index if need */
5571 insta_art = (k_info[k_idx].gen_flags & TRG_INSTA_ART);
5572 fixed_art = (amuse_info[i].flag & AMS_FIXED_ART);
5574 if (insta_art || fixed_art)
5576 for (a_idx = 1; a_idx < max_a_idx; a_idx++)
5578 if (insta_art && !(a_info[a_idx].gen_flags & TRG_INSTA_ART)) continue;
5579 if (a_info[a_idx].tval != k_info[k_idx].tval) continue;
5580 if (a_info[a_idx].sval != k_info[k_idx].sval) continue;
5581 if (a_info[a_idx].cur_num > 0) continue;
5585 if (a_idx >= max_a_idx) continue;
5588 /* Make an object (if possible) */
5589 object_prep(i_ptr, k_idx);
5590 if (a_idx) i_ptr->name1 = a_idx;
5591 apply_magic(i_ptr, 1, AM_NO_FIXED_ART);
5593 if (amuse_info[i].flag & AMS_NO_UNIQUE)
5595 if (r_info[i_ptr->pval].flags1 & RF1_UNIQUE) continue;
5598 if (amuse_info[i].flag & AMS_MULTIPLE) i_ptr->number = randint1(3);
5599 if (amuse_info[i].flag & AMS_PILE) i_ptr->number = randint1(99);
5603 object_aware(i_ptr);
5604 object_known(i_ptr);
5607 /* Paranoia - reroll if nothing */
5608 if (!(i_ptr->k_idx)) continue;
5610 /* Drop the object */
5611 (void)drop_near(i_ptr, -1, y1, x1);
5618 #define MAX_NORMAL_TRAPS 18
5620 /* See init_feat_variables() in init2.c */
5621 static s16b normal_traps[MAX_NORMAL_TRAPS];
5624 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
5627 void init_normal_traps(void)
5631 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
5632 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
5633 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
5634 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
5635 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
5636 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
5637 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
5638 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
5639 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
5640 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
5641 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
5642 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
5643 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
5644 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
5645 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
5646 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
5647 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
5648 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
5652 * @brief 基本トラップをランダムに選択する /
5654 * @return 選択したトラップのID
5656 * XXX XXX XXX This routine should be redone to reflect trap "level".\n
5657 * That is, it does not make sense to have spiked pits at 50 feet.\n
5658 * Actually, it is not this routine, but the "trap instantiation"\n
5659 * code, which should also check for "trap doors" on quest levels.\n
5661 s16b choose_random_trap(void)
5668 /* Hack -- pick a trap */
5669 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
5671 /* Accept non-trapdoors */
5672 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
5674 /* Hack -- no trap doors on special levels */
5675 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
5677 /* Hack -- no trap doors on the deepest level */
5678 if (dun_level >= d_info[dungeon_type].maxdepth) continue;
5687 * @brief マスに存在するトラップを秘匿する /
5688 * Disclose an invisible trap
5689 * @param y 秘匿したいマスのY座標
5690 * @param x 秘匿したいマスのX座標
5693 void disclose_grid(int y, int x)
5695 cave_type *c_ptr = &cave[y][x];
5697 if (cave_have_flag_grid(c_ptr, FF_SECRET))
5699 /* No longer hidden */
5700 cave_alter_feat(y, x, FF_SECRET);
5702 else if (c_ptr->mimic)
5704 /* No longer hidden */
5716 * @brief マスをトラップを配置する /
5717 * The location must be a legal, naked, floor grid.
5718 * @param y 配置したいマスのY座標
5719 * @param x 配置したいマスのX座標
5721 * Note that all traps start out as "invisible" and "untyped", and then\n
5722 * when they are "discovered" (by detecting them or setting them off),\n
5723 * the trap is "instantiated" as a visible, "typed", trap.\n
5725 void place_trap(int y, int x)
5727 cave_type *c_ptr = &cave[y][x];
5729 /* Paranoia -- verify location */
5730 if (!in_bounds(y, x)) return;
5732 /* Require empty, clean, floor grid */
5733 if (!cave_clean_bold(y, x)) return;
5735 /* Place an invisible trap */
5736 c_ptr->mimic = c_ptr->feat;
5737 c_ptr->feat = choose_random_trap();
5741 * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
5742 * Describe the charges on an item in the inventory.
5743 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5746 void inven_item_charges(int item)
5748 object_type *o_ptr = &inventory[item];
5750 /* Require staff/wand */
5751 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5753 /* Require known item */
5754 if (!object_is_known(o_ptr)) return;
5757 if (o_ptr->pval <= 0)
5759 msg_print("もう魔力が残っていない。");
5763 msg_format("あと %d 回分の魔力が残っている。", o_ptr->pval);
5766 /* Multiple charges */
5767 if (o_ptr->pval != 1)
5769 /* Print a message */
5770 msg_format("You have %d charges remaining.", o_ptr->pval);
5776 /* Print a message */
5777 msg_format("You have %d charge remaining.", o_ptr->pval);
5784 * @brief アイテムの残り所持数メッセージを表示する /
5785 * Describe an item in the inventory.
5786 * @param item 残量を表示したいプレイヤーのアイテム所持スロット
5789 void inven_item_describe(int item)
5791 object_type *o_ptr = &inventory[item];
5792 char o_name[MAX_NLEN];
5794 /* Get a description */
5795 object_desc(o_name, o_ptr, 0);
5797 /* Print a message */
5799 /* "no more" の場合はこちらで表示する */
5800 if (o_ptr->number <= 0)
5802 /*FIRST*//*ここはもう通らないかも */
5803 msg_format("もう%sを持っていない。", o_name);
5807 /* アイテム名を英日切り替え機能対応 */
5808 msg_format("まだ %sを持っている。", o_name);
5811 msg_format("You have %s.", o_name);
5817 * @brief アイテムの残り所持数メッセージを表示する /
5818 * Increase the "number" of an item in the inventory
5819 * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
5823 void inven_item_increase(int item, int num)
5825 object_type *o_ptr = &inventory[item];
5828 num += o_ptr->number;
5831 if (num > 255) num = 255;
5832 else if (num < 0) num = 0;
5835 num -= o_ptr->number;
5837 /* Change the number and weight */
5840 /* Add the number */
5841 o_ptr->number += num;
5843 /* Add the weight */
5844 p_ptr->total_weight += (num * o_ptr->weight);
5846 /* Recalculate bonuses */
5847 p_ptr->update |= (PU_BONUS);
5849 /* Recalculate mana XXX */
5850 p_ptr->update |= (PU_MANA);
5852 /* Combine the pack */
5853 p_ptr->notice |= (PN_COMBINE);
5856 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5858 /* Hack -- Clear temporary elemental brands if player takes off weapons */
5859 if (!o_ptr->number && p_ptr->ele_attack)
5861 if ((item == INVEN_RARM) || (item == INVEN_LARM))
5863 if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
5865 /* Clear all temporary elemental brands */
5866 set_ele_attack(0, 0);
5874 * @brief 所持アイテムスロットから所持数のなくなったアイテムを消去する /
5875 * Erase an inventory slot if it has no more items
5876 * @param item 消去したいプレイヤーのアイテム所持スロット
5879 void inven_item_optimize(int item)
5881 object_type *o_ptr = &inventory[item];
5883 /* Only optimize real items */
5884 if (!o_ptr->k_idx) return;
5886 /* Only optimize empty items */
5887 if (o_ptr->number) return;
5889 /* The item is in the pack */
5890 if (item < INVEN_RARM)
5897 /* Slide everything down */
5898 for (i = item; i < INVEN_PACK; i++)
5900 /* Structure copy */
5901 inventory[i] = inventory[i+1];
5904 /* Erase the "final" slot */
5905 object_wipe(&inventory[i]);
5908 p_ptr->window |= (PW_INVEN);
5911 /* The item is being wielded */
5917 /* Erase the empty slot */
5918 object_wipe(&inventory[item]);
5920 /* Recalculate bonuses */
5921 p_ptr->update |= (PU_BONUS);
5923 /* Recalculate torch */
5924 p_ptr->update |= (PU_TORCH);
5926 /* Recalculate mana XXX */
5927 p_ptr->update |= (PU_MANA);
5930 p_ptr->window |= (PW_EQUIP);
5934 p_ptr->window |= (PW_SPELL);
5938 * @brief 床上の魔道具の残り残量メッセージを表示する /
5939 * Describe the charges on an item on the floor.
5940 * @param item メッセージの対象にしたいアイテム所持スロット
5943 void floor_item_charges(int item)
5945 object_type *o_ptr = &o_list[item];
5947 /* Require staff/wand */
5948 if ((o_ptr->tval != TV_STAFF) && (o_ptr->tval != TV_WAND)) return;
5950 /* Require known item */
5951 if (!object_is_known(o_ptr)) return;
5954 if (o_ptr->pval <= 0)
5956 msg_print("この床上のアイテムは、もう魔力が残っていない。");
5960 msg_format("この床上のアイテムは、あと %d 回分の魔力が残っている。", o_ptr->pval);
5963 /* Multiple charges */
5964 if (o_ptr->pval != 1)
5966 /* Print a message */
5967 msg_format("There are %d charges remaining.", o_ptr->pval);
5973 /* Print a message */
5974 msg_format("There is %d charge remaining.", o_ptr->pval);
5981 * @brief 床上のアイテムの残り数メッセージを表示する /
5982 * Describe the charges on an item on the floor.
5983 * @param item メッセージの対象にしたいアイテム所持スロット
5986 void floor_item_describe(int item)
5988 object_type *o_ptr = &o_list[item];
5989 char o_name[MAX_NLEN];
5991 /* Get a description */
5992 object_desc(o_name, o_ptr, 0);
5994 /* Print a message */
5996 /* "no more" の場合はこちらで表示を分ける */
5997 if (o_ptr->number <= 0)
5999 msg_format("床上には、もう%sはない。", o_name);
6003 msg_format("床上には、まだ %sがある。", o_name);
6006 msg_format("You see %s.", o_name);
6013 * @brief 床上のアイテムの数を増やす /
6014 * Increase the "number" of an item on the floor
6015 * @param item 増やしたいアイテムの所持スロット
6016 * @param num 増やしたいアイテムの数
6019 void floor_item_increase(int item, int num)
6021 object_type *o_ptr = &o_list[item];
6024 num += o_ptr->number;
6027 if (num > 255) num = 255;
6028 else if (num < 0) num = 0;
6031 num -= o_ptr->number;
6033 /* Change the number */
6034 o_ptr->number += num;
6039 * @brief 床上の数の無くなったアイテムスロットを消去する /
6040 * Optimize an item on the floor (destroy "empty" items)
6041 * @param item 消去したいアイテムの所持スロット
6044 void floor_item_optimize(int item)
6046 object_type *o_ptr = &o_list[item];
6048 /* Paranoia -- be sure it exists */
6049 if (!o_ptr->k_idx) return;
6051 /* Only optimize empty items */
6052 if (o_ptr->number) return;
6054 /* Delete the object */
6055 delete_object_idx(item);
6060 * @brief アイテムを拾う際にザックから溢れずに済むかを判定する /
6061 * Check if we have space for an item in the pack without overflow
6062 * @param o_ptr 拾いたいオブジェクトの構造体参照ポインタ
6063 * @return 溢れずに済むならTRUEを返す
6065 bool inven_carry_okay(object_type *o_ptr)
6070 if (inven_cnt < INVEN_PACK) return (TRUE);
6073 for (j = 0; j < INVEN_PACK; j++)
6075 object_type *j_ptr = &inventory[j];
6077 /* Skip non-objects */
6078 if (!j_ptr->k_idx) continue;
6080 /* Check if the two items can be combined */
6081 if (object_similar(j_ptr, o_ptr)) return (TRUE);
6089 * @brief オブジェクトを定義された基準に従いソートするための関数 /
6090 * Check if we have space for an item in the pack without overflow
6091 * @param o_ptr 比較対象オブジェクトの構造体参照ポインタ1
6092 * @param o_value o_ptrのアイテム価値(手動であらかじめ代入する必要がある?)
6093 * @param j_ptr 比較対象オブジェクトの構造体参照ポインタ2
6094 * @return o_ptrの方が上位ならばTRUEを返す。
6096 bool object_sort_comp(object_type *o_ptr, s32b o_value, object_type *j_ptr)
6100 /* Use empty slots */
6101 if (!j_ptr->k_idx) return TRUE;
6103 /* Hack -- readable books always come first */
6104 if ((o_ptr->tval == REALM1_BOOK) &&
6105 (j_ptr->tval != REALM1_BOOK)) return TRUE;
6106 if ((j_ptr->tval == REALM1_BOOK) &&
6107 (o_ptr->tval != REALM1_BOOK)) return FALSE;
6109 if ((o_ptr->tval == REALM2_BOOK) &&
6110 (j_ptr->tval != REALM2_BOOK)) return TRUE;
6111 if ((j_ptr->tval == REALM2_BOOK) &&
6112 (o_ptr->tval != REALM2_BOOK)) return FALSE;
6114 /* Objects sort by decreasing type */
6115 if (o_ptr->tval > j_ptr->tval) return TRUE;
6116 if (o_ptr->tval < j_ptr->tval) return FALSE;
6118 /* Non-aware (flavored) items always come last */
6119 /* Can happen in the home */
6120 if (!object_is_aware(o_ptr)) return FALSE;
6121 if (!object_is_aware(j_ptr)) return TRUE;
6123 /* Objects sort by increasing sval */
6124 if (o_ptr->sval < j_ptr->sval) return TRUE;
6125 if (o_ptr->sval > j_ptr->sval) return FALSE;
6127 /* Unidentified objects always come last */
6128 /* Objects in the home can be unknown */
6129 if (!object_is_known(o_ptr)) return FALSE;
6130 if (!object_is_known(j_ptr)) return TRUE;
6132 /* Fixed artifacts, random artifacts and ego items */
6133 if (object_is_fixed_artifact(o_ptr)) o_type = 3;
6134 else if (o_ptr->art_name) o_type = 2;
6135 else if (object_is_ego(o_ptr)) o_type = 1;
6138 if (object_is_fixed_artifact(j_ptr)) j_type = 3;
6139 else if (j_ptr->art_name) j_type = 2;
6140 else if (object_is_ego(j_ptr)) j_type = 1;
6143 if (o_type < j_type) return TRUE;
6144 if (o_type > j_type) return FALSE;
6146 switch (o_ptr->tval)
6152 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) return TRUE;
6153 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) return TRUE;
6159 /* Objects sort by increasing hit/damage bonuses */
6160 if (o_ptr->to_h + o_ptr->to_d < j_ptr->to_h + j_ptr->to_d) return TRUE;
6161 if (o_ptr->to_h + o_ptr->to_d > j_ptr->to_h + j_ptr->to_d) return FALSE;
6164 /* Hack: otherwise identical rods sort by
6165 increasing recharge time --dsb */
6167 if (o_ptr->pval < j_ptr->pval) return TRUE;
6168 if (o_ptr->pval > j_ptr->pval) return FALSE;
6172 /* Objects sort by decreasing value */
6173 return o_value > object_value(j_ptr);
6178 * @brief オブジェクトをプレイヤーが拾って所持スロットに納めるメインルーチン /
6179 * Add an item to the players inventory, and return the slot used.
6180 * @param o_ptr 拾うオブジェクトの構造体参照ポインタ
6181 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6183 * If the new item can combine with an existing item in the inventory,\n
6184 * it will do so, using "object_similar()" and "object_absorb()", else,\n
6185 * the item will be placed into the "proper" location in the inventory.\n
6187 * This function can be used to "over-fill" the player's pack, but only\n
6188 * once, and such an action must trigger the "overflow" code immediately.\n
6189 * Note that when the pack is being "over-filled", the new item must be\n
6190 * placed into the "overflow" slot, and the "overflow" must take place\n
6191 * before the pack is reordered, but (optionally) after the pack is\n
6192 * combined. This may be tricky. See "dungeon.c" for info.\n
6194 * Note that this code must remove any location/stack information\n
6195 * from the object once it is placed into the inventory.\n
6197 s16b inven_carry(object_type *o_ptr)
6205 /* Check for combining */
6206 for (j = 0; j < INVEN_PACK; j++)
6208 j_ptr = &inventory[j];
6210 /* Skip non-objects */
6211 if (!j_ptr->k_idx) continue;
6213 /* Hack -- track last item */
6216 /* Check if the two items can be combined */
6217 if (object_similar(j_ptr, o_ptr))
6219 /* Combine the items */
6220 object_absorb(j_ptr, o_ptr);
6222 /* Increase the weight */
6223 p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
6225 /* Recalculate bonuses */
6226 p_ptr->update |= (PU_BONUS);
6229 p_ptr->window |= (PW_INVEN);
6238 if (inven_cnt > INVEN_PACK) return (-1);
6240 /* Find an empty slot */
6241 for (j = 0; j <= INVEN_PACK; j++)
6243 j_ptr = &inventory[j];
6245 /* Use it if found */
6246 if (!j_ptr->k_idx) break;
6253 /* Reorder the pack */
6256 /* Get the "value" of the item */
6257 s32b o_value = object_value(o_ptr);
6259 /* Scan every occupied slot */
6260 for (j = 0; j < INVEN_PACK; j++)
6262 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6269 for (k = n; k >= i; k--)
6271 /* Hack -- Slide the item */
6272 object_copy(&inventory[k+1], &inventory[k]);
6275 /* Wipe the empty slot */
6276 object_wipe(&inventory[i]);
6281 object_copy(&inventory[i], o_ptr);
6283 /* Access new object */
6284 j_ptr = &inventory[i];
6287 j_ptr->next_o_idx = 0;
6289 /* Forget monster */
6290 j_ptr->held_m_idx = 0;
6292 /* Forget location */
6293 j_ptr->iy = j_ptr->ix = 0;
6295 /* Player touches it, and no longer marked */
6296 j_ptr->marked = OM_TOUCHED;
6298 /* Increase the weight */
6299 p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
6301 /* Count the items */
6304 /* Recalculate bonuses */
6305 p_ptr->update |= (PU_BONUS);
6307 /* Combine and Reorder pack */
6308 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6311 p_ptr->window |= (PW_INVEN);
6313 /* Return the slot */
6319 * @brief 装備スロットからオブジェクトを外すメインルーチン /
6320 * Take off (some of) a non-cursed equipment item
6321 * @param item オブジェクトを外したい所持テーブルのID
6323 * @return 収められた所持スロットのID、拾うことができなかった場合-1を返す。
6325 * Note that only one item at a time can be wielded per slot.\n
6326 * Note that taking off an item when "full" may cause that item\n
6327 * to fall to the ground.\n
6328 * Return the inventory slot into which the item is placed.\n
6330 s16b inven_takeoff(int item, int amt)
6341 char o_name[MAX_NLEN];
6344 /* Get the item to take off */
6345 o_ptr = &inventory[item];
6348 if (amt <= 0) return (-1);
6351 if (amt > o_ptr->number) amt = o_ptr->number;
6353 /* Get local object */
6356 /* Obtain a local object */
6357 object_copy(q_ptr, o_ptr);
6359 /* Modify quantity */
6360 q_ptr->number = amt;
6362 /* Describe the object */
6363 object_desc(o_name, q_ptr, 0);
6365 /* Took off weapon */
6366 if (((item == INVEN_RARM) || (item == INVEN_LARM)) &&
6367 object_is_melee_weapon(o_ptr))
6369 act = _("を装備からはずした", "You were wielding");
6373 else if (item == INVEN_BOW)
6375 act = _("を装備からはずした", "You were holding");
6378 /* Took off light */
6379 else if (item == INVEN_LITE)
6381 act = _("を光源からはずした", "You were holding");
6384 /* Took off something */
6387 act = _("を装備からはずした", "You were wearing");
6390 /* Modify, Optimize */
6391 inven_item_increase(item, -amt);
6392 inven_item_optimize(item);
6394 /* Carry the object */
6395 slot = inven_carry(q_ptr);
6399 msg_format("%s(%c)%s。", o_name, index_to_label(slot), act);
6401 msg_format("%s %s (%c).", act, o_name, index_to_label(slot));
6411 * @brief 所持スロットから床下にオブジェクトを落とすメインルーチン /
6412 * Drop (some of) a non-cursed inventory/equipment item
6413 * @param item 所持テーブルのID
6414 * @param amt 落としたい個数
6417 * The object will be dropped "near" the current location
6419 void inven_drop(int item, int amt)
6426 char o_name[MAX_NLEN];
6429 /* Access original object */
6430 o_ptr = &inventory[item];
6433 if (amt <= 0) return;
6436 if (amt > o_ptr->number) amt = o_ptr->number;
6439 /* Take off equipment */
6440 if (item >= INVEN_RARM)
6442 /* Take off first */
6443 item = inven_takeoff(item, amt);
6445 /* Access original object */
6446 o_ptr = &inventory[item];
6450 /* Get local object */
6453 /* Obtain local object */
6454 object_copy(q_ptr, o_ptr);
6456 /* Distribute charges of wands or rods */
6457 distribute_charges(o_ptr, q_ptr, amt);
6459 /* Modify quantity */
6460 q_ptr->number = amt;
6462 /* Describe local object */
6463 object_desc(o_name, q_ptr, 0);
6466 msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
6468 /* Drop it near the player */
6469 (void)drop_near(q_ptr, 0, py, px);
6471 /* Modify, Describe, Optimize */
6472 inven_item_increase(item, -amt);
6473 inven_item_describe(item);
6474 inven_item_optimize(item);
6479 * @brief プレイヤーの所持スロットに存在するオブジェクトをまとめなおす /
6480 * Combine items in the pack
6483 * Note special handling of the "overflow" slot
6485 void combine_pack(void)
6490 bool flag = FALSE, combined;
6496 /* Combine the pack (backwards) */
6497 for (i = INVEN_PACK; i > 0; i--)
6500 o_ptr = &inventory[i];
6502 /* Skip empty items */
6503 if (!o_ptr->k_idx) continue;
6505 /* Scan the items above that item */
6506 for (j = 0; j < i; j++)
6511 j_ptr = &inventory[j];
6513 /* Skip empty items */
6514 if (!j_ptr->k_idx) continue;
6517 * Get maximum number of the stack if these
6518 * are similar, get zero otherwise.
6520 max_num = object_similar_part(j_ptr, o_ptr);
6522 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
6523 if (max_num && j_ptr->number < max_num)
6525 if (o_ptr->number + j_ptr->number <= max_num)
6530 /* Add together the item counts */
6531 object_absorb(j_ptr, o_ptr);
6533 /* One object is gone */
6536 /* Slide everything down */
6537 for (k = i; k < INVEN_PACK; k++)
6539 /* Structure copy */
6540 inventory[k] = inventory[k+1];
6543 /* Erase the "final" slot */
6544 object_wipe(&inventory[k]);
6548 int old_num = o_ptr->number;
6549 int remain = j_ptr->number + o_ptr->number - max_num;
6551 o_ptr->number -= remain;
6553 /* Add together the item counts */
6554 object_absorb(j_ptr, o_ptr);
6556 o_ptr->number = remain;
6558 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
6559 if (o_ptr->tval == TV_ROD)
6561 o_ptr->pval = o_ptr->pval * remain / old_num;
6562 o_ptr->timeout = o_ptr->timeout * remain / old_num;
6565 /* Hack -- if wands are stacking, combine the charges. -LM- */
6566 if (o_ptr->tval == TV_WAND)
6568 o_ptr->pval = o_ptr->pval * remain / old_num;
6573 p_ptr->window |= (PW_INVEN);
6587 if (flag) msg_print(_("ザックの中のアイテムをまとめ直した。", "You combine some items in your pack."));
6591 * @brief プレイヤーの所持スロットに存在するオブジェクトを並び替える /
6592 * Reorder items in the pack
6595 * Note special handling of the "overflow" slot
6597 void reorder_pack(void)
6607 /* Re-order the pack (forwards) */
6608 for (i = 0; i < INVEN_PACK; i++)
6610 /* Mega-Hack -- allow "proper" over-flow */
6611 if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
6614 o_ptr = &inventory[i];
6616 /* Skip empty slots */
6617 if (!o_ptr->k_idx) continue;
6619 /* Get the "value" of the item */
6620 o_value = object_value(o_ptr);
6622 /* Scan every occupied slot */
6623 for (j = 0; j < INVEN_PACK; j++)
6625 if (object_sort_comp(o_ptr, o_value, &inventory[j])) break;
6628 /* Never move down */
6629 if (j >= i) continue;
6634 /* Get local object */
6637 /* Save a copy of the moving item */
6638 object_copy(q_ptr, &inventory[i]);
6640 /* Slide the objects */
6641 for (k = i; k > j; k--)
6643 /* Slide the item */
6644 object_copy(&inventory[k], &inventory[k-1]);
6647 /* Insert the moving item */
6648 object_copy(&inventory[j], q_ptr);
6651 p_ptr->window |= (PW_INVEN);
6655 if (flag) msg_print(_("ザックの中のアイテムを並べ直した。", "You reorder some items in your pack."));
6659 * @brief 現在アクティブになっているウィンドウにオブジェクトの詳細を表示する /
6660 * Hack -- display an object kind in the current window
6661 * @param k_idx ベースアイテムの参照ID
6664 * Include list of usable spells for readible books
6666 void display_koff(int k_idx)
6675 char o_name[MAX_NLEN];
6678 /* Erase the window */
6679 for (y = 0; y < Term->hgt; y++)
6681 /* Erase the line */
6682 Term_erase(0, y, 255);
6688 /* Get local object */
6691 /* Prepare the object */
6692 object_prep(q_ptr, k_idx);
6695 object_desc(o_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY | OD_STORE));
6697 /* Mention the object name */
6698 Term_putstr(0, 0, -1, TERM_WHITE, o_name);
6700 /* Access the item's sval */
6702 use_realm = tval2realm(q_ptr->tval);
6704 /* Warriors are illiterate */
6705 if (p_ptr->realm1 || p_ptr->realm2)
6707 if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) return;
6711 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return;
6712 if (!is_magic(use_realm)) return;
6713 if ((p_ptr->pclass == CLASS_RED_MAGE) && (use_realm != REALM_ARCANE) && (sval > 1)) return;
6716 /* Display spells in readible books */
6722 /* Extract spells */
6723 for (spell = 0; spell < 32; spell++)
6725 /* Check for this spell */
6726 if (fake_spell_flags[sval] & (1L << spell))
6728 /* Collect this spell */
6729 spells[num++] = spell;
6734 print_spells(0, spells, num, 2, 0, use_realm);
6739 * @brief 警告を放つアイテムを選択する /
6740 * Choose one of items that have warning flag
6741 * Calculate spell damages
6744 object_type *choose_warning_item(void)
6747 int choices[INVEN_TOTAL - INVEN_RARM];
6750 /* Paranoia -- Player has no warning ability */
6751 if (!p_ptr->warning) return NULL;
6753 /* Search Inventory */
6754 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6756 u32b flgs[TR_FLAG_SIZE];
6757 object_type *o_ptr = &inventory[i];
6759 object_flags(o_ptr, flgs);
6760 if (have_flag(flgs, TR_WARNING))
6762 choices[number] = i;
6767 /* Choice one of them */
6768 return number ? &inventory[choices[randint0(number)]] : NULL;
6772 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6773 * Calculate spell damages
6774 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6775 * @param typ 効果属性のID
6777 * @param max 算出した最大ダメージを返すポインタ
6780 static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int *max)
6782 monster_race *r_ptr = &r_info[m_ptr->r_idx];
6783 int rlev = r_ptr->level;
6784 bool ignore_wraith_form = FALSE;
6786 /* Vulnerability, resistance and immunity */
6790 if (p_ptr->immune_elec)
6793 ignore_wraith_form = TRUE;
6797 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6798 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6799 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6800 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6801 if (IS_OPPOSE_ELEC())
6802 dam = (dam + 2) / 3;
6807 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6808 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6812 if (p_ptr->immune_acid)
6815 ignore_wraith_form = TRUE;
6819 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6820 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6821 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6822 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6828 if (p_ptr->immune_cold)
6831 ignore_wraith_form = TRUE;
6835 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6836 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6837 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6838 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6843 if (p_ptr->immune_fire)
6846 ignore_wraith_form = TRUE;
6850 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6851 if (prace_is_(RACE_ENT)) dam += dam / 3;
6852 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6853 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6854 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6859 ignore_wraith_form = TRUE;
6863 if (!p_ptr->blind &&
6864 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6865 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6868 ignore_wraith_form = TRUE;
6873 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6874 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6875 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6878 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6879 * "dam *= 2;" for later "dam /= 2"
6881 if (p_ptr->wraith_form) dam *= 2;
6885 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6888 ignore_wraith_form = TRUE;
6890 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6894 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6898 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6902 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6906 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6910 if (prace_is_(RACE_SPECTRE))
6913 ignore_wraith_form = TRUE;
6915 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6919 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6923 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6927 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6931 if (p_ptr->levitation) dam = (dam * 2) / 3;
6935 if (p_ptr->resist_shard) dam /= 2;
6939 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6940 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6944 if (p_ptr->mimic_form)
6946 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6949 ignore_wraith_form = TRUE;
6954 switch (p_ptr->prace)
6963 ignore_wraith_form = TRUE;
6970 if (p_ptr->align > 10) dam /= 2;
6971 else if (p_ptr->align < -10) dam *= 2;
6975 if (p_ptr->align > 10) dam *= 2;
6979 case GF_BRAIN_SMASH:
6980 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6983 ignore_wraith_form = TRUE;
6991 if (100 + rlev / 2 <= p_ptr->skill_sav)
6994 ignore_wraith_form = TRUE;
6999 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
7002 ignore_wraith_form = TRUE;
7007 if (p_ptr->wraith_form && !ignore_wraith_form)
7013 if (dam > *max) *max = dam;
7017 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
7018 * Calculate spell damages
7019 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
7020 * @param typ 効果属性のID
7021 * @param m_idx 魔法を行使するモンスターのID
7022 * @param max 算出した最大ダメージを返すポインタ
7025 void spell_damcalc_by_spellnum(int spell_num, int typ, int m_idx, int *max)
7027 monster_type *m_ptr = &m_list[m_idx];
7028 int dam = monspell_damage((spell_num), m_idx, DAM_MAX);
7029 spell_damcalc(m_ptr, typ, dam, max);
7033 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
7034 * Calculate blow damages
7035 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
7036 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
7037 * @return 算出された最大ダメージを返す。
7039 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
7041 int dam = blow_ptr->d_dice * blow_ptr->d_side;
7043 bool check_wraith_form = TRUE;
7045 if (blow_ptr->method != RBM_EXPLODE)
7047 int ac = p_ptr->ac + p_ptr->to_a;
7049 switch (blow_ptr->effect)
7053 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
7054 dam = MAX(dam, tmp_dam * 2);
7060 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
7064 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
7066 check_wraith_form = FALSE;
7070 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
7072 check_wraith_form = FALSE;
7076 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
7078 check_wraith_form = FALSE;
7082 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
7084 check_wraith_form = FALSE;
7089 check_wraith_form = FALSE;
7093 if (check_wraith_form && p_ptr->wraith_form)
7101 dam = (dam + 1) / 2;
7102 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
7110 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
7111 * Examine the grid (xx,yy) and warn the player if there are any danger
7112 * @param xx 危険性を調査するマスのX座標
7113 * @param yy 危険性を調査するマスのY座標
7114 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
7116 bool process_warning(int xx, int yy)
7120 char o_name[MAX_NLEN];
7122 #define WARNING_AWARE_RANGE 12
7124 static int old_damage = 0;
7126 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
7128 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
7131 monster_type *m_ptr;
7132 monster_race *r_ptr;
7134 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
7136 c_ptr = &cave[my][mx];
7138 if (!c_ptr->m_idx) continue;
7140 m_ptr = &m_list[c_ptr->m_idx];
7142 if (MON_CSLEEP(m_ptr)) continue;
7143 if (!is_hostile(m_ptr)) continue;
7145 r_ptr = &r_info[m_ptr->r_idx];
7147 /* Monster spells (only powerful ones)*/
7148 if (projectable(my, mx, yy, xx))
7150 u32b f4 = r_ptr->flags4;
7151 u32b f5 = r_ptr->flags5;
7152 u32b f6 = r_ptr->flags6;
7154 if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
7156 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7157 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7158 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7159 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, c_ptr->m_idx, &dam_max0);
7160 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, c_ptr->m_idx, &dam_max0);
7161 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, c_ptr->m_idx, &dam_max0);
7163 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, c_ptr->m_idx, &dam_max0);
7164 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, c_ptr->m_idx, &dam_max0);
7165 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, c_ptr->m_idx, &dam_max0);
7166 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, c_ptr->m_idx, &dam_max0);
7167 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, c_ptr->m_idx, &dam_max0);
7168 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, c_ptr->m_idx, &dam_max0);
7169 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, c_ptr->m_idx, &dam_max0);
7170 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, c_ptr->m_idx, &dam_max0);
7171 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, c_ptr->m_idx, &dam_max0);
7172 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, c_ptr->m_idx, &dam_max0);
7173 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, c_ptr->m_idx, &dam_max0);
7174 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, c_ptr->m_idx, &dam_max0);
7175 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
7176 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
7177 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
7178 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIA, c_ptr->m_idx, &dam_max0);
7179 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
7180 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
7181 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
7182 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, c_ptr->m_idx, &dam_max0);
7183 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, c_ptr->m_idx, &dam_max0);
7184 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, c_ptr->m_idx, &dam_max0);
7185 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, c_ptr->m_idx, &dam_max0);
7188 /* Monster melee attacks */
7189 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[dungeon_type].flags1 & DF1_NO_MELEE))
7191 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
7195 for (m = 0; m < 4; m++)
7197 /* Skip non-attacks */
7198 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
7200 /* Extract the attack info */
7201 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
7202 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
7204 if (dam_melee > dam_max0) dam_max0 = dam_melee;
7208 /* Contribution from this monster */
7209 dam_max += dam_max0;
7213 /* Prevent excessive warning */
7214 if (dam_max > old_damage)
7216 old_damage = dam_max * 3 / 2;
7218 if (dam_max > p_ptr->chp / 2)
7220 object_type *o_ptr = choose_warning_item();
7223 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7225 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7226 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7229 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7232 else old_damage = old_damage / 2;
7234 c_ptr = &cave[yy][xx];
7235 if (((!easy_disarm && is_trap(c_ptr->feat))
7236 || (c_ptr->mimic && is_trap(c_ptr->feat))) && !one_in_(13))
7238 object_type *o_ptr = choose_warning_item();
7241 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7243 strcpy(o_name, _("体", "body")); /* Warning ability without item */
7244 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
7246 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
7253 * @brief エッセンスの付加可能な武器や矢弾かを返す
7254 * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
7255 * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
7257 static bool item_tester_hook_melee_ammo(object_type *o_ptr)
7259 switch (o_ptr->tval)
7272 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
7281 * エッセンス情報の構造体 / A structure for smithing
7284 int add; /* TR flag number or special essence id */
7285 cptr add_name; /* Name of this ability */
7286 int type; /* Menu number */
7287 int essence; /* Index for carrying essences */
7288 int value; /* Needed value to add this ability */
7293 * エッセンス情報テーブル Smithing type data for Weapon smith
7296 static essence_type essence_info[] =
7298 {TR_STR, "腕力", 4, TR_STR, 20},
7299 {TR_INT, "知能", 4, TR_INT, 20},
7300 {TR_WIS, "賢さ", 4, TR_WIS, 20},
7301 {TR_DEX, "器用さ", 4, TR_DEX, 20},
7302 {TR_CON, "耐久力", 4, TR_CON, 20},
7303 {TR_CHR, "魅力", 4, TR_CHR, 20},
7304 {TR_MAGIC_MASTERY, "魔力支配", 4, TR_MAGIC_MASTERY, 20},
7305 {TR_STEALTH, "隠密", 4, TR_STEALTH, 40},
7306 {TR_SEARCH, "探索", 4, TR_SEARCH, 15},
7307 {TR_INFRA, "赤外線視力", 4, TR_INFRA, 15},
7308 {TR_TUNNEL, "採掘", 4, TR_TUNNEL, 15},
7309 {TR_SPEED, "スピード", 4, TR_SPEED, 12},
7310 {TR_BLOWS, "追加攻撃", 1, TR_BLOWS, 20},
7311 {TR_CHAOTIC, "カオス攻撃", 1, TR_CHAOTIC, 15},
7312 {TR_VAMPIRIC, "吸血攻撃", 1, TR_VAMPIRIC, 60},
7313 {TR_IMPACT, "地震発動", 7, TR_IMPACT, 15},
7314 {TR_BRAND_POIS, "毒殺", 1, TR_BRAND_POIS, 20},
7315 {TR_BRAND_ACID, "溶解", 1, TR_BRAND_ACID, 20},
7316 {TR_BRAND_ELEC, "電撃", 1, TR_BRAND_ELEC, 20},
7317 {TR_BRAND_FIRE, "焼棄", 1, TR_BRAND_FIRE, 20},
7318 {TR_BRAND_COLD, "凍結", 1, TR_BRAND_COLD, 20},
7319 {TR_SUST_STR, "腕力維持", 3, TR_SUST_STR, 15},
7320 {TR_SUST_INT, "知能維持", 3, TR_SUST_STR, 15},
7321 {TR_SUST_WIS, "賢さ維持", 3, TR_SUST_STR, 15},
7322 {TR_SUST_DEX, "器用さ維持", 3, TR_SUST_STR, 15},
7323 {TR_SUST_CON, "耐久力維持", 3, TR_SUST_STR, 15},
7324 {TR_SUST_CHR, "魅力維持", 3, TR_SUST_STR, 15},
7325 {TR_IM_ACID, "酸免疫", 2, TR_IM_ACID, 20},
7326 {TR_IM_ELEC, "電撃免疫", 2, TR_IM_ACID, 20},
7327 {TR_IM_FIRE, "火炎免疫", 2, TR_IM_ACID, 20},
7328 {TR_IM_COLD, "冷気免疫", 2, TR_IM_ACID, 20},
7329 {TR_REFLECT, "反射", 2, TR_REFLECT, 20},
7330 {TR_FREE_ACT, "麻痺知らず", 3, TR_FREE_ACT, 20},
7331 {TR_HOLD_EXP, "経験値維持", 3, TR_HOLD_EXP, 20},
7332 {TR_RES_ACID, "耐酸", 2, TR_RES_ACID, 15},
7333 {TR_RES_ELEC, "耐電撃", 2, TR_RES_ELEC, 15},
7334 {TR_RES_FIRE, "耐火炎", 2, TR_RES_FIRE, 15},
7335 {TR_RES_COLD, "耐冷気", 2, TR_RES_COLD, 15},
7336 {TR_RES_POIS, "耐毒", 2, TR_RES_POIS, 25},
7337 {TR_RES_FEAR, "耐恐怖", 2, TR_RES_FEAR, 20},
7338 {TR_RES_LITE, "耐閃光", 2, TR_RES_LITE, 20},
7339 {TR_RES_DARK, "耐暗黒", 2, TR_RES_DARK, 20},
7340 {TR_RES_BLIND, "耐盲目", 2, TR_RES_BLIND, 20},
7341 {TR_RES_CONF, "耐混乱", 2, TR_RES_CONF, 20},
7342 {TR_RES_SOUND, "耐轟音", 2, TR_RES_SOUND, 20},
7343 {TR_RES_SHARDS, "耐破片", 2, TR_RES_SHARDS, 20},
7344 {TR_RES_NETHER, "耐地獄", 2, TR_RES_NETHER, 20},
7345 {TR_RES_NEXUS, "耐因果混乱", 2, TR_RES_NEXUS, 20},
7346 {TR_RES_CHAOS, "耐カオス", 2, TR_RES_CHAOS, 20},
7347 {TR_RES_DISEN, "耐劣化", 2, TR_RES_DISEN, 20},
7348 {TR_SH_FIRE, "", 0, -2, 0},
7349 {TR_SH_ELEC, "", 0, -2, 0},
7350 {TR_SH_COLD, "", 0, -2, 0},
7351 {TR_NO_MAGIC, "反魔法", 3, TR_NO_MAGIC, 15},
7352 {TR_WARNING, "警告", 3, TR_WARNING, 20},
7353 {TR_LEVITATION, "浮遊", 3, TR_LEVITATION, 20},
7354 {TR_LITE_1, "永久光源", 3, TR_LITE_1, 15},
7355 {TR_LITE_2, "", 0, -2, 0},
7356 {TR_LITE_3, "", 0, -2, 0},
7357 {TR_SEE_INVIS, "可視透明", 3, TR_SEE_INVIS, 20},
7358 {TR_TELEPATHY, "テレパシー", 6, TR_TELEPATHY, 15},
7359 {TR_SLOW_DIGEST, "遅消化", 3, TR_SLOW_DIGEST, 15},
7360 {TR_REGEN, "急速回復", 3, TR_REGEN, 20},
7361 {TR_TELEPORT, "テレポート", 3, TR_TELEPORT, 25},
7363 {TR_SLAY_EVIL, "邪悪倍打", 5, TR_SLAY_EVIL, 100},
7364 {TR_KILL_EVIL, "邪悪倍倍打", 0, TR_SLAY_EVIL, 60},
7365 {TR_SLAY_ANIMAL, "動物倍打", 5, TR_SLAY_ANIMAL, 20},
7366 {TR_KILL_ANIMAL, "動物倍倍打", 5, TR_SLAY_ANIMAL, 60},
7367 {TR_SLAY_UNDEAD, "不死倍打", 5, TR_SLAY_UNDEAD, 20},
7368 {TR_KILL_UNDEAD, "不死倍倍打", 5, TR_SLAY_UNDEAD, 60},
7369 {TR_SLAY_DEMON, "悪魔倍打", 5, TR_SLAY_DEMON, 20},
7370 {TR_KILL_DEMON, "悪魔倍倍打", 5, TR_SLAY_DEMON, 60},
7371 {TR_SLAY_ORC, "オーク倍打", 5, TR_SLAY_ORC, 15},
7372 {TR_KILL_ORC, "オーク倍倍打", 5, TR_SLAY_ORC, 60},
7373 {TR_SLAY_TROLL, "トロル倍打", 5, TR_SLAY_TROLL, 15},
7374 {TR_KILL_TROLL, "トロル倍倍打", 5, TR_SLAY_TROLL, 60},
7375 {TR_SLAY_GIANT, "巨人倍打", 5, TR_SLAY_GIANT, 20},
7376 {TR_KILL_GIANT, "巨人倍倍打", 5, TR_SLAY_GIANT, 60},
7377 {TR_SLAY_DRAGON, "竜倍打", 5, TR_SLAY_DRAGON, 20},
7378 {TR_KILL_DRAGON, "竜倍倍打", 5, TR_SLAY_DRAGON, 60},
7379 {TR_SLAY_HUMAN, "人間倍打", 5, TR_SLAY_HUMAN, 20},
7380 {TR_KILL_HUMAN, "人間倍倍打", 5, TR_SLAY_HUMAN, 60},
7382 {TR_ESP_ANIMAL, "動物ESP", 6, TR_SLAY_ANIMAL, 40},
7383 {TR_ESP_UNDEAD, "不死ESP", 6, TR_SLAY_UNDEAD, 40},
7384 {TR_ESP_DEMON, "悪魔ESP", 6, TR_SLAY_DEMON, 40},
7385 {TR_ESP_ORC, "オークESP", 6, TR_SLAY_ORC, 40},
7386 {TR_ESP_TROLL, "トロルESP", 6, TR_SLAY_TROLL, 40},
7387 {TR_ESP_GIANT, "巨人ESP", 6, TR_SLAY_GIANT, 40},
7388 {TR_ESP_DRAGON, "竜ESP", 6, TR_SLAY_DRAGON, 40},
7389 {TR_ESP_HUMAN, "人間ESP", 6, TR_SLAY_HUMAN, 40},
7391 {ESSENCE_ATTACK, "攻撃", 10, TR_ES_ATTACK, 30},
7392 {ESSENCE_AC, "防御", 10, TR_ES_AC, 15},
7393 {ESSENCE_TMP_RES_ACID, "酸耐性発動", 7, TR_RES_ACID, 50},
7394 {ESSENCE_TMP_RES_ELEC, "電撃耐性発動", 7, TR_RES_ELEC, 50},
7395 {ESSENCE_TMP_RES_FIRE, "火炎耐性発動", 7, TR_RES_FIRE, 50},
7396 {ESSENCE_TMP_RES_COLD, "冷気耐性発動", 7, TR_RES_COLD, 50},
7397 {ESSENCE_SH_FIRE, "火炎オーラ", 7, -1, 50},
7398 {ESSENCE_SH_ELEC, "電撃オーラ", 7, -1, 50},
7399 {ESSENCE_SH_COLD, "冷気オーラ", 7, -1, 50},
7400 {ESSENCE_RESISTANCE, "全耐性", 2, -1, 150},
7401 {ESSENCE_SUSTAIN, "装備保持", 10, -1, 10},
7402 {ESSENCE_SLAY_GLOVE, "殺戮の小手", 1, TR_ES_ATTACK, 200},
7404 {-1, NULL, 0, -1, 0}
7407 static essence_type essence_info[] =
7409 {TR_STR, "strength", 4, TR_STR, 20},
7410 {TR_INT, "intelligence", 4, TR_INT, 20},
7411 {TR_WIS, "wisdom", 4, TR_WIS, 20},
7412 {TR_DEX, "dexterity", 4, TR_DEX, 20},
7413 {TR_CON, "constitution", 4, TR_CON, 20},
7414 {TR_CHR, "charisma", 4, TR_CHR, 20},
7415 {TR_MAGIC_MASTERY, "magic mastery", 4, TR_MAGIC_MASTERY, 20},
7416 {TR_STEALTH, "stealth", 4, TR_STEALTH, 40},
7417 {TR_SEARCH, "serching", 4, TR_SEARCH, 15},
7418 {TR_INFRA, "infravision", 4, TR_INFRA, 15},
7419 {TR_TUNNEL, "digging", 4, TR_TUNNEL, 15},
7420 {TR_SPEED, "speed", 4, TR_SPEED, 12},
7421 {TR_BLOWS, "extra attack", 1, TR_BLOWS, 20},
7422 {TR_CHAOTIC, "chaos brand", 1, TR_CHAOTIC, 15},
7423 {TR_VAMPIRIC, "vampiric brand", 1, TR_VAMPIRIC, 60},
7424 {TR_IMPACT, "quake activation", 7, TR_IMPACT, 15},
7425 {TR_BRAND_POIS, "poison brand", 1, TR_BRAND_POIS, 20},
7426 {TR_BRAND_ACID, "acid brand", 1, TR_BRAND_ACID, 20},
7427 {TR_BRAND_ELEC, "electric brand", 1, TR_BRAND_ELEC, 20},
7428 {TR_BRAND_FIRE, "fire brand", 1, TR_BRAND_FIRE, 20},
7429 {TR_BRAND_COLD, "cold brand", 1, TR_BRAND_COLD, 20},
7430 {TR_SUST_STR, "sustain strength", 3, TR_SUST_STR, 15},
7431 {TR_SUST_INT, "sustain intelligence", 3, TR_SUST_STR, 15},
7432 {TR_SUST_WIS, "sustain wisdom", 3, TR_SUST_STR, 15},
7433 {TR_SUST_DEX, "sustain dexterity", 3, TR_SUST_STR, 15},
7434 {TR_SUST_CON, "sustain constitution", 3, TR_SUST_STR, 15},
7435 {TR_SUST_CHR, "sustain charisma", 3, TR_SUST_STR, 15},
7436 {TR_IM_ACID, "acid immunity", 2, TR_IM_ACID, 20},
7437 {TR_IM_ELEC, "electric immunity", 2, TR_IM_ACID, 20},
7438 {TR_IM_FIRE, "fire immunity", 2, TR_IM_ACID, 20},
7439 {TR_IM_COLD, "cold immunity", 2, TR_IM_ACID, 20},
7440 {TR_REFLECT, "reflection", 2, TR_REFLECT, 20},
7441 {TR_FREE_ACT, "free action", 3, TR_FREE_ACT, 20},
7442 {TR_HOLD_EXP, "hold experience", 3, TR_HOLD_EXP, 20},
7443 {TR_RES_ACID, "resistance to acid", 2, TR_RES_ACID, 15},
7444 {TR_RES_ELEC, "resistance to electric", 2, TR_RES_ELEC, 15},
7445 {TR_RES_FIRE, "resistance to fire", 2, TR_RES_FIRE, 15},
7446 {TR_RES_COLD, "resistance to cold", 2, TR_RES_COLD, 15},
7447 {TR_RES_POIS, "resistance to poison", 2, TR_RES_POIS, 25},
7448 {TR_RES_FEAR, "resistance to fear", 2, TR_RES_FEAR, 20},
7449 {TR_RES_LITE, "resistance to light", 2, TR_RES_LITE, 20},
7450 {TR_RES_DARK, "resistance to dark", 2, TR_RES_DARK, 20},
7451 {TR_RES_BLIND, "resistance to blind", 2, TR_RES_BLIND, 20},
7452 {TR_RES_CONF, "resistance to confusion", 2, TR_RES_CONF, 20},
7453 {TR_RES_SOUND, "resistance to sound", 2, TR_RES_SOUND, 20},
7454 {TR_RES_SHARDS, "resistance to shard", 2, TR_RES_SHARDS, 20},
7455 {TR_RES_NETHER, "resistance to nether", 2, TR_RES_NETHER, 20},
7456 {TR_RES_NEXUS, "resistance to nexus", 2, TR_RES_NEXUS, 20},
7457 {TR_RES_CHAOS, "resistance to chaos", 2, TR_RES_CHAOS, 20},
7458 {TR_RES_DISEN, "resistance to disenchantment", 2, TR_RES_DISEN, 20},
7459 {TR_SH_FIRE, "", 0, -2, 0},
7460 {TR_SH_ELEC, "", 0, -2, 0},
7461 {TR_SH_COLD, "", 0, -2, 0},
7462 {TR_NO_MAGIC, "anti magic", 3, TR_NO_MAGIC, 15},
7463 {TR_WARNING, "warning", 3, TR_WARNING, 20},
7464 {TR_LEVITATION, "levitation", 3, TR_LEVITATION, 20},
7465 {TR_LITE_1, "permanent light", 3, TR_LITE_1, 15},
7466 {TR_LITE_2, "", 0, -2, 0},
7467 {TR_LITE_3, "", 0, -2, 0},
7468 {TR_SEE_INVIS, "see invisible", 3, TR_SEE_INVIS, 20},
7469 {TR_TELEPATHY, "telepathy", 6, TR_TELEPATHY, 15},
7470 {TR_SLOW_DIGEST, "slow digestion", 3, TR_SLOW_DIGEST, 15},
7471 {TR_REGEN, "regeneration", 3, TR_REGEN, 20},
7472 {TR_TELEPORT, "teleport", 3, TR_TELEPORT, 25},
7474 {TR_SLAY_EVIL, "slay evil", 5, TR_SLAY_EVIL, 100},
7475 {TR_SLAY_ANIMAL, "slay animal", 5, TR_SLAY_ANIMAL, 20},
7476 {TR_KILL_ANIMAL, "kill animal", 5, TR_SLAY_ANIMAL, 60},
7477 {TR_KILL_EVIL, "kill evil", 0, TR_SLAY_EVIL, 60},
7478 {TR_SLAY_UNDEAD, "slay undead", 5, TR_SLAY_UNDEAD, 20},
7479 {TR_KILL_UNDEAD, "kill undead", 5, TR_SLAY_UNDEAD, 60},
7480 {TR_SLAY_DEMON, "slay demon", 5, TR_SLAY_DEMON, 20},
7481 {TR_KILL_DEMON, "kill demon", 5, TR_SLAY_DEMON, 60},
7482 {TR_SLAY_ORC, "slay orc", 5, TR_SLAY_ORC, 15},
7483 {TR_KILL_ORC, "kill orc", 5, TR_SLAY_ORC, 60},
7484 {TR_SLAY_TROLL, "slay troll", 5, TR_SLAY_TROLL, 15},
7485 {TR_KILL_TROLL, "kill troll", 5, TR_SLAY_TROLL, 60},
7486 {TR_SLAY_GIANT, "slay giant", 5, TR_SLAY_GIANT, 20},
7487 {TR_KILL_GIANT, "kill giant", 5, TR_SLAY_GIANT, 60},
7488 {TR_SLAY_DRAGON, "slay dragon", 5, TR_SLAY_DRAGON, 20},
7489 {TR_KILL_DRAGON, "kill dragon", 5, TR_SLAY_DRAGON, 60},
7490 {TR_SLAY_HUMAN, "slay human", 5, TR_SLAY_HUMAN, 20},
7491 {TR_KILL_HUMAN, "kill human", 5, TR_SLAY_HUMAN, 60},
7493 {TR_ESP_ANIMAL, "sense animal", 6, TR_SLAY_ANIMAL, 40},
7494 {TR_ESP_UNDEAD, "sense undead", 6, TR_SLAY_UNDEAD, 40},
7495 {TR_ESP_DEMON, "sense demon", 6, TR_SLAY_DEMON, 40},
7496 {TR_ESP_ORC, "sense orc", 6, TR_SLAY_ORC, 40},
7497 {TR_ESP_TROLL, "sense troll", 6, TR_SLAY_TROLL, 40},
7498 {TR_ESP_GIANT, "sense giant", 6, TR_SLAY_GIANT, 40},
7499 {TR_ESP_DRAGON, "sense dragon", 6, TR_SLAY_DRAGON, 40},
7500 {TR_ESP_HUMAN, "sense human", 6, TR_SLAY_HUMAN, 40},
7502 {ESSENCE_ATTACK, "weapon enchant", 10, TR_ES_ATTACK, 30},
7503 {ESSENCE_AC, "armor enchant", 10, TR_ES_AC, 15},
7504 {ESSENCE_TMP_RES_ACID, "resist acid activation", 7, TR_RES_ACID, 50},
7505 {ESSENCE_TMP_RES_ELEC, "resist electricity activation", 7, TR_RES_ELEC, 50},
7506 {ESSENCE_TMP_RES_FIRE, "resist fire activation", 7, TR_RES_FIRE, 50},
7507 {ESSENCE_TMP_RES_COLD, "resist cold activation", 7, TR_RES_COLD, 50},
7508 {ESSENCE_SH_FIRE, "fiery sheath", 7, -1, 50},
7509 {ESSENCE_SH_ELEC, "electric sheath", 7, -1, 50},
7510 {ESSENCE_SH_COLD, "sheath of coldness", 7, -1, 50},
7511 {ESSENCE_RESISTANCE, "resistance", 2, -1, 150},
7512 {ESSENCE_SUSTAIN, "elements proof", 10, -1, 10},
7513 {ESSENCE_SLAY_GLOVE, "gauntlets of slaying", 1, TR_ES_ATTACK, 200},
7515 {-1, NULL, 0, -1, 0}
7521 * エッセンス名テーブル / Essense names for Weapon smith
7524 cptr essence_name[] =
7627 cptr essence_name[] =
7730 * @brief 所持しているエッセンス一覧を表示する
7733 static void display_essence(void)
7738 for (i = 1; i < 22; i++)
7742 prt(_("エッセンス 個数 エッセンス 個数 エッセンス 個数",
7743 "Essence Num Essence Num Essence Num "), 1, 8);
7744 for (i = 0; essence_name[i]; i++)
7746 if (!essence_name[i][0]) continue;
7747 prt(format("%-11s %5d", essence_name[i], p_ptr->magic_num1[i]), 2+num%21, 8+num/21*22);
7750 prt(_("現在所持しているエッセンス", "List of all essences you have."), 0, 0);
7760 static void drain_essence(void)
7762 int drain_value[sizeof(p_ptr->magic_num1) / sizeof(s32b)];
7765 bool observe = FALSE;
7766 int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
7767 u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
7770 byte iy, ix, marked, number;
7771 s16b next_o_idx, weight;
7773 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7776 item_tester_hook = object_is_weapon_armour_ammo;
7777 item_tester_no_ryoute = TRUE;
7780 q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
7781 s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
7783 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
7785 /* Get the item (in the pack) */
7788 o_ptr = &inventory[item];
7791 /* Get the item (on the floor) */
7794 o_ptr = &o_list[0 - item];
7797 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
7799 char o_name[MAX_NLEN];
7800 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
7801 if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
7806 object_flags(o_ptr, old_flgs);
7807 if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
7808 if (have_flag(old_flgs, TR_KILL_ANIMAL)) add_flag(old_flgs, TR_SLAY_ANIMAL);
7809 if (have_flag(old_flgs, TR_KILL_EVIL)) add_flag(old_flgs, TR_SLAY_EVIL);
7810 if (have_flag(old_flgs, TR_KILL_UNDEAD)) add_flag(old_flgs, TR_SLAY_UNDEAD);
7811 if (have_flag(old_flgs, TR_KILL_DEMON)) add_flag(old_flgs, TR_SLAY_DEMON);
7812 if (have_flag(old_flgs, TR_KILL_ORC)) add_flag(old_flgs, TR_SLAY_ORC);
7813 if (have_flag(old_flgs, TR_KILL_TROLL)) add_flag(old_flgs, TR_SLAY_TROLL);
7814 if (have_flag(old_flgs, TR_KILL_GIANT)) add_flag(old_flgs, TR_SLAY_GIANT);
7815 if (have_flag(old_flgs, TR_KILL_HUMAN)) add_flag(old_flgs, TR_SLAY_HUMAN);
7817 old_to_a = o_ptr->to_a;
7819 old_to_h = o_ptr->to_h;
7820 old_to_d = o_ptr->to_d;
7823 old_pval = o_ptr->pval;
7824 old_name2 = o_ptr->name2;
7825 old_timeout = o_ptr->timeout;
7826 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) dec--;
7827 if (have_flag(old_flgs, TR_ADD_L_CURSE)) dec--;
7828 if (have_flag(old_flgs, TR_ADD_H_CURSE)) dec--;
7829 if (have_flag(old_flgs, TR_AGGRAVATE)) dec--;
7830 if (have_flag(old_flgs, TR_NO_TELE)) dec--;
7831 if (have_flag(old_flgs, TR_DRAIN_EXP)) dec--;
7832 if (have_flag(old_flgs, TR_DRAIN_HP)) dec--;
7833 if (have_flag(old_flgs, TR_DRAIN_MANA)) dec--;
7834 if (have_flag(old_flgs, TR_CALL_ANIMAL)) dec--;
7835 if (have_flag(old_flgs, TR_CALL_DEMON)) dec--;
7836 if (have_flag(old_flgs, TR_CALL_DRAGON)) dec--;
7837 if (have_flag(old_flgs, TR_CALL_UNDEAD)) dec--;
7838 if (have_flag(old_flgs, TR_COWARDICE)) dec--;
7839 if (have_flag(old_flgs, TR_LOW_MELEE)) dec--;
7840 if (have_flag(old_flgs, TR_LOW_AC)) dec--;
7841 if (have_flag(old_flgs, TR_LOW_MAGIC)) dec--;
7842 if (have_flag(old_flgs, TR_FAST_DIGEST)) dec--;
7843 if (have_flag(old_flgs, TR_SLOW_REGEN)) dec--;
7844 if (have_flag(old_flgs, TR_TY_CURSE)) dec--;
7848 next_o_idx = o_ptr->next_o_idx;
7849 marked = o_ptr->marked;
7850 weight = o_ptr->weight;
7851 number = o_ptr->number;
7853 object_prep(o_ptr, o_ptr->k_idx);
7857 o_ptr->next_o_idx=next_o_idx;
7858 o_ptr->marked=marked;
7859 o_ptr->number = number;
7860 if (o_ptr->tval == TV_DRAG_ARMOR) o_ptr->timeout = old_timeout;
7861 if (item >= 0) p_ptr->total_weight += (o_ptr->weight*o_ptr->number - weight*number);
7862 o_ptr->ident |= (IDENT_MENTAL);
7863 object_aware(o_ptr);
7864 object_known(o_ptr);
7866 object_flags(o_ptr, new_flgs);
7868 for (i = 0; essence_info[i].add_name; i++)
7870 essence_type *es_ptr = &essence_info[i];
7873 if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
7874 pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
7876 if (es_ptr->add < TR_FLAG_MAX &&
7877 (!have_flag(new_flgs, es_ptr->add) || pval) &&
7878 have_flag(old_flgs, es_ptr->add))
7882 drain_value[es_ptr->essence] += 10 * pval;
7884 else if (es_ptr->essence != -2)
7886 drain_value[es_ptr->essence] += 10;
7888 else if (es_ptr->add == TR_SH_FIRE)
7890 drain_value[TR_BRAND_FIRE] += 10;
7891 drain_value[TR_RES_FIRE] += 10;
7893 else if (es_ptr->add == TR_SH_ELEC)
7895 drain_value[TR_BRAND_ELEC] += 10;
7896 drain_value[TR_RES_ELEC] += 10;
7898 else if (es_ptr->add == TR_SH_COLD)
7900 drain_value[TR_BRAND_COLD] += 10;
7901 drain_value[TR_RES_COLD] += 10;
7903 else if (es_ptr->add == TR_LITE_2)
7905 drain_value[TR_LITE_1] += 20;
7907 else if (es_ptr->add == TR_LITE_3)
7909 drain_value[TR_LITE_1] += 30;
7914 if ((have_flag(old_flgs, TR_FORCE_WEAPON)) && !(have_flag(new_flgs, TR_FORCE_WEAPON)))
7916 drain_value[TR_INT] += 5;
7917 drain_value[TR_WIS] += 5;
7919 if ((have_flag(old_flgs, TR_VORPAL)) && !(have_flag(new_flgs, TR_VORPAL)))
7921 drain_value[TR_BRAND_POIS] += 5;
7922 drain_value[TR_BRAND_ACID] += 5;
7923 drain_value[TR_BRAND_ELEC] += 5;
7924 drain_value[TR_BRAND_FIRE] += 5;
7925 drain_value[TR_BRAND_COLD] += 5;
7927 if ((have_flag(old_flgs, TR_DEC_MANA)) && !(have_flag(new_flgs, TR_DEC_MANA)))
7929 drain_value[TR_INT] += 10;
7931 if ((have_flag(old_flgs, TR_XTRA_MIGHT)) && !(have_flag(new_flgs, TR_XTRA_MIGHT)))
7933 drain_value[TR_STR] += 10;
7935 if ((have_flag(old_flgs, TR_XTRA_SHOTS)) && !(have_flag(new_flgs, TR_XTRA_SHOTS)))
7937 drain_value[TR_DEX] += 10;
7939 if (old_name2 == EGO_2WEAPON)
7941 drain_value[TR_DEX] += 20;
7943 if (object_is_weapon_ammo(o_ptr))
7945 if (old_ds > o_ptr->ds) drain_value[TR_ES_ATTACK] += (old_ds-o_ptr->ds)*10;
7947 if (old_dd > o_ptr->dd) drain_value[TR_ES_ATTACK] += (old_dd-o_ptr->dd)*10;
7949 if (old_to_h > o_ptr->to_h) drain_value[TR_ES_ATTACK] += (old_to_h-o_ptr->to_h)*10;
7950 if (old_to_d > o_ptr->to_d) drain_value[TR_ES_ATTACK] += (old_to_d-o_ptr->to_d)*10;
7951 if (old_ac > o_ptr->ac) drain_value[TR_ES_AC] += (old_ac-o_ptr->ac)*10;
7952 if (old_to_a > o_ptr->to_a) drain_value[TR_ES_AC] += (old_to_a-o_ptr->to_a)*10;
7954 for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
7956 drain_value[i] *= number;
7957 drain_value[i] = drain_value[i] * dec / 4;
7958 drain_value[i] = MAX(drain_value[i], 0);
7959 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) drain_value[i] /= 10;
7967 msg_print(_("エッセンスは抽出できませんでした。", "You were not able to extract any essence."));
7971 msg_print(_("抽出したエッセンス:", "Extracted essences:"));
7973 for (i = 0; essence_name[i]; i++)
7975 if (!essence_name[i][0]) continue;
7976 if (!drain_value[i]) continue;
7978 p_ptr->magic_num1[i] += drain_value[i];
7979 p_ptr->magic_num1[i] = MIN(20000, p_ptr->magic_num1[i]);
7981 msg_format("%s...%d%s", essence_name[i], drain_value[i], _("。", ". "));
7985 /* Apply autodestroy/inscription to the drained item */
7986 autopick_alter_item(item, TRUE);
7988 /* Combine the pack */
7989 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
7992 p_ptr->window |= (PW_INVEN);
7996 * @brief 付加するエッセンスの大別を選択する
7997 * @return 選んだエッセンスの大別ID
7999 static int choose_essence(void)
8003 int menu_line = (use_menu ? 1 : 0);
8006 cptr menu_name[] = {
8016 cptr menu_name[] = {
8026 const int mode_max = 7;
8029 if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
8032 #endif /* ALLOW_REPEAT */
8041 for (i = 0; i < mode_max; i++)
8043 prt(format(" %s %s", (menu_line == 1+i) ? "》" : " ", menu_name[i]), 2 + i, 14);
8044 prt("どの種類のエッセンス付加を行いますか?", 0, 0);
8046 prt(format(" %s %s", (menu_line == 1+i) ? "> " : " ", menu_name[i]), 2 + i, 14);
8047 prt("Choose from menu.", 0, 0);
8066 menu_line += mode_max - 1;
8075 if (menu_line > mode_max) menu_line -= mode_max;
8086 for (i = 0; i < mode_max; i++)
8087 prt(format(" %c) %s", 'a' + i, menu_name[i]), 2 + i, 14);
8089 if (!get_com(_("何を付加しますか:", "Command :"), &choice, TRUE))
8095 if (isupper(choice)) choice = tolower(choice);
8097 if ('a' <= choice && choice <= 'a' + (char)mode_max - 1)
8098 mode = (int)choice - 'a' + 1;
8105 #endif /* ALLOW_REPEAT */
8110 * @brief エッセンスを実際に付加する
8111 * @param mode エッセンスの大別ID
8114 static void add_essence(int mode)
8116 int item, max_num = 0;
8125 char o_name[MAX_NLEN];
8127 essence_type *es_ptr;
8129 int menu_line = (use_menu ? 1 : 0);
8131 for (i = 0; essence_info[i].add_name; i++)
8133 es_ptr = &essence_info[i];
8135 if (es_ptr->type != mode) continue;
8140 if (!repeat_pull(&i) || i<0 || i>=max_num)
8142 #endif /* ALLOW_REPEAT */
8145 /* Nothing chosen yet */
8151 /* Build a prompt */
8152 (void) strnfmt(out_val, 78, _("('*'で一覧, ESCで中断) どの能力を付加しますか?", "(*=List, ESC=exit) Add which ability? "));
8153 if (use_menu) screen_save();
8155 /* Get a spell from the user */
8157 choice = (always_show_list || use_menu) ? ESCAPE:1;
8161 if( choice==ESCAPE ) choice = ' ';
8162 else if( !get_com(out_val, &choice, FALSE) )break;
8164 if (use_menu && choice != ' ')
8178 menu_line += (max_num-1);
8201 menu_line = max_num;
8215 if (menu_line > max_num) menu_line -= max_num;
8217 /* Request redraw */
8218 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
8221 if (!redraw || use_menu)
8225 char dummy[80], dummy2[80];
8233 /* Save the screen */
8234 if (!use_menu) screen_save();
8236 for (y = 1; y < 24; y++)
8239 /* Print header(s) */
8241 prt(format(" %-43s %6s/%s", "能力(必要エッセンス)", "必要数", "所持数"), 1, x);
8244 prt(format(" %-43s %6s/%s", "Ability (needed essence)", "Needs", "Possess"), 1, x);
8247 for (ctr = 0; ctr < max_num; ctr++)
8249 es_ptr = &essence_info[num[ctr]];
8253 if (ctr == (menu_line-1))
8254 strcpy(dummy, _("》 ", "> "));
8255 else strcpy(dummy, " ");
8258 /* letter/number for power selection */
8261 sprintf(dummy, "%c) ",I2A(ctr));
8264 strcat(dummy, es_ptr->add_name);
8269 if (es_ptr->essence != -1)
8271 strcat(dummy, format("(%s)", essence_name[es_ptr->essence]));
8272 if (p_ptr->magic_num1[es_ptr->essence] < es_ptr->value) able[ctr] = FALSE;
8278 case ESSENCE_SH_FIRE:
8279 strcat(dummy, _("(焼棄+耐火炎)", "(brand fire + res.fire)"));
8280 if (p_ptr->magic_num1[TR_BRAND_FIRE] < es_ptr->value) able[ctr] = FALSE;
8281 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8283 case ESSENCE_SH_ELEC:
8284 strcat(dummy, _("(電撃+耐電撃)", "(brand elec. + res. elec.)"));
8285 if (p_ptr->magic_num1[TR_BRAND_ELEC] < es_ptr->value) able[ctr] = FALSE;
8286 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8288 case ESSENCE_SH_COLD:
8289 strcat(dummy, _("(凍結+耐冷気)", "(brand cold + res. cold)"));
8290 if (p_ptr->magic_num1[TR_BRAND_COLD] < es_ptr->value) able[ctr] = FALSE;
8291 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8293 case ESSENCE_RESISTANCE:
8294 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8295 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8296 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8297 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8298 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8300 case ESSENCE_SUSTAIN:
8301 strcat(dummy, _("(耐火炎+耐冷気+耐電撃+耐酸)", "(r.fire+r.cold+r.elec+r.acid)"));
8302 if (p_ptr->magic_num1[TR_RES_FIRE] < es_ptr->value) able[ctr] = FALSE;
8303 if (p_ptr->magic_num1[TR_RES_COLD] < es_ptr->value) able[ctr] = FALSE;
8304 if (p_ptr->magic_num1[TR_RES_ELEC] < es_ptr->value) able[ctr] = FALSE;
8305 if (p_ptr->magic_num1[TR_RES_ACID] < es_ptr->value) able[ctr] = FALSE;
8310 if (!able[ctr]) col = TERM_RED;
8312 if (es_ptr->essence != -1)
8314 sprintf(dummy2, "%-49s %3d/%d", dummy, es_ptr->value, (int)p_ptr->magic_num1[es_ptr->essence]);
8318 sprintf(dummy2, "%-49s %3d/(\?\?)", dummy, es_ptr->value);
8321 c_prt(col, dummy2, ctr+2, x);
8331 /* Restore the screen */
8342 ask = (isupper(choice));
8345 if (ask) choice = tolower(choice);
8347 /* Extract request */
8348 i = (islower(choice) ? A2I(choice) : -1);
8351 /* Totally Illegal */
8352 if ((i < 0) || (i >= max_num) || !able[i])
8364 (void) strnfmt(tmp_val, 78, _("%sを付加しますか? ", "Add the abilitiy of %s? "), essence_info[num[i]].add_name);
8366 /* Belay that order */
8367 if (!get_check(tmp_val)) continue;
8374 /* Restore the screen */
8375 if (redraw) screen_load();
8382 #endif /* ALLOW_REPEAT */
8384 es_ptr = &essence_info[num[i]];
8386 if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8387 item_tester_tval = TV_GLOVES;
8388 else if (mode == 1 || mode == 5)
8389 item_tester_hook = item_tester_hook_melee_ammo;
8390 else if (es_ptr->add == ESSENCE_ATTACK)
8391 item_tester_hook = object_allow_enchant_weapon;
8392 else if (es_ptr->add == ESSENCE_AC)
8393 item_tester_hook = object_is_armour;
8395 item_tester_hook = object_is_weapon_armour_ammo;
8396 item_tester_no_ryoute = TRUE;
8399 q = _("どのアイテムを改良しますか?", "Improve which item? ");
8400 s = _("改良できるアイテムがありません。", "You have nothing to improve.");
8402 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8404 /* Get the item (in the pack) */
8407 o_ptr = &inventory[item];
8410 /* Get the item (on the floor) */
8413 o_ptr = &o_list[0 - item];
8416 if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
8418 msg_print(_("そのアイテムはこれ以上改良できない。", "This item is no more able to be improved."));
8422 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8424 use_essence = es_ptr->value;
8425 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_BOLT)) use_essence = (use_essence+9)/10;
8426 if (o_ptr->number > 1)
8428 use_essence *= o_ptr->number;
8429 msg_format(_("%d個あるのでエッセンスは%d必要です。", "It will take %d essences."), o_ptr->number, use_essence);
8432 if (es_ptr->essence != -1)
8434 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8436 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8439 if (is_pval_flag(es_ptr->add))
8441 if (o_ptr->pval < 0)
8443 msg_print(_("このアイテムの能力修正を強化することはできない。", "You cannot increase magic number of this item."));
8446 else if (es_ptr->add == TR_BLOWS)
8448 if (o_ptr->pval > 1)
8450 if (!get_check(_("修正値は1になります。よろしいですか?", "The magic number of this weapon will become 1. Are you sure? "))) return;
8454 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8456 else if (o_ptr->pval > 0)
8458 use_essence *= o_ptr->pval;
8459 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8466 int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
8468 sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
8469 strcpy(tmp_val, "1");
8471 if (!get_string(tmp, tmp_val, 1)) return;
8472 pval = atoi(tmp_val);
8473 if (pval > limit) pval = limit;
8474 else if (pval < 1) pval = 1;
8475 o_ptr->pval += pval;
8476 use_essence *= pval;
8477 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8480 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8482 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8486 else if (es_ptr->add == ESSENCE_SLAY_GLOVE)
8490 int get_to_h, get_to_d;
8492 strcpy(tmp_val, "1");
8493 if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;
8494 val = atoi(tmp_val);
8495 if (val > p_ptr->lev/7+3) val = p_ptr->lev/7+3;
8496 else if (val < 1) val = 1;
8498 msg_format(_("エッセンスを%d個使用します。", "It will take %d essences."), use_essence);
8499 if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
8501 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8504 get_to_h = ((val+1)/2+randint0(val/2+1));
8505 get_to_d = ((val+1)/2+randint0(val/2+1));
8506 o_ptr->xtra4 = (get_to_h<<8)+get_to_d;
8507 o_ptr->to_h += get_to_h;
8508 o_ptr->to_d += get_to_d;
8510 p_ptr->magic_num1[es_ptr->essence] -= use_essence;
8511 if (es_ptr->add == ESSENCE_ATTACK)
8513 if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
8515 msg_print(_("改良に失敗した。", "You failed to enchant."));
8521 if (o_ptr->to_h < p_ptr->lev/5+5) o_ptr->to_h++;
8522 if (o_ptr->to_d < p_ptr->lev/5+5) o_ptr->to_d++;
8525 else if (es_ptr->add == ESSENCE_AC)
8527 if (o_ptr->to_a >= p_ptr->lev/5+5)
8529 msg_print(_("改良に失敗した。", "You failed to enchant."));
8535 if (o_ptr->to_a < p_ptr->lev/5+5) o_ptr->to_a++;
8540 o_ptr->xtra3 = es_ptr->add + 1;
8545 bool success = TRUE;
8549 case ESSENCE_SH_FIRE:
8550 if ((p_ptr->magic_num1[TR_BRAND_FIRE] < use_essence) || (p_ptr->magic_num1[TR_RES_FIRE] < use_essence))
8555 p_ptr->magic_num1[TR_BRAND_FIRE] -= use_essence;
8556 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8558 case ESSENCE_SH_ELEC:
8559 if ((p_ptr->magic_num1[TR_BRAND_ELEC] < use_essence) || (p_ptr->magic_num1[TR_RES_ELEC] < use_essence))
8564 p_ptr->magic_num1[TR_BRAND_ELEC] -= use_essence;
8565 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8567 case ESSENCE_SH_COLD:
8568 if ((p_ptr->magic_num1[TR_BRAND_COLD] < use_essence) || (p_ptr->magic_num1[TR_RES_COLD] < use_essence))
8573 p_ptr->magic_num1[TR_BRAND_COLD] -= use_essence;
8574 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8576 case ESSENCE_RESISTANCE:
8577 case ESSENCE_SUSTAIN:
8578 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))
8583 p_ptr->magic_num1[TR_RES_ACID] -= use_essence;
8584 p_ptr->magic_num1[TR_RES_ELEC] -= use_essence;
8585 p_ptr->magic_num1[TR_RES_FIRE] -= use_essence;
8586 p_ptr->magic_num1[TR_RES_COLD] -= use_essence;
8591 msg_print(_("エッセンスが足りない。", "You don't have enough essences."));
8594 if (es_ptr->add == ESSENCE_SUSTAIN)
8596 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
8597 add_flag(o_ptr->art_flags, TR_IGNORE_ELEC);
8598 add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
8599 add_flag(o_ptr->art_flags, TR_IGNORE_COLD);
8603 o_ptr->xtra3 = es_ptr->add + 1;
8610 msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
8612 msg_format("You have added ability of %s to %s.", es_ptr->add_name, o_name);
8615 /* Combine the pack */
8616 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8619 p_ptr->window |= (PW_INVEN);
8626 static void erase_essence(void)
8631 char o_name[MAX_NLEN];
8632 u32b flgs[TR_FLAG_SIZE];
8634 item_tester_hook = object_is_smith;
8637 q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
8638 s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
8640 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
8642 /* Get the item (in the pack) */
8645 o_ptr = &inventory[item];
8648 /* Get the item (on the floor) */
8651 o_ptr = &o_list[0 - item];
8654 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
8655 if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
8659 if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
8661 o_ptr->to_h -= (o_ptr->xtra4>>8);
8662 o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
8664 if (o_ptr->to_h < 0) o_ptr->to_h = 0;
8665 if (o_ptr->to_d < 0) o_ptr->to_d = 0;
8668 object_flags(o_ptr, flgs);
8669 if (!(have_pval_flags(flgs))) o_ptr->pval = 0;
8670 msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
8672 /* Combine the pack */
8673 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
8676 p_ptr->window |= (PW_INVEN);
8680 * @brief 鍛冶コマンドのメインルーチン
8681 * @param only_browse TRUEならばエッセンス一覧の表示のみを行う
8684 void do_cmd_kaji(bool only_browse)
8689 int menu_line = (use_menu ? 1 : 0);
8693 if (p_ptr->confused)
8695 msg_print(_("混乱していて作業できない!", "You are too confused!"));
8700 msg_print(_("目が見えなくて作業できない!", "You are blind!"));
8705 msg_print(_("うまく見えなくて作業できない!", "You are hallucinating!"));
8711 if (!(repeat_pull(&mode) && 1 <= mode && mode <= 5))
8713 #endif /* ALLOW_REPEAT */
8715 if (only_browse) screen_save();
8717 if (!only_browse) screen_save();
8723 prt(format(" %s エッセンス一覧", (menu_line == 1) ? "》" : " "), 2, 14);
8724 prt(format(" %s エッセンス抽出", (menu_line == 2) ? "》" : " "), 3, 14);
8725 prt(format(" %s エッセンス消去", (menu_line == 3) ? "》" : " "), 4, 14);
8726 prt(format(" %s エッセンス付加", (menu_line == 4) ? "》" : " "), 5, 14);
8727 prt(format(" %s 武器/防具強化", (menu_line == 5) ? "》" : " "), 6, 14);
8728 prt(format("どの種類の技術を%sますか?", only_browse ? "調べ" : "使い"), 0, 0);
8730 prt(format(" %s List essences", (menu_line == 1) ? "> " : " "), 2, 14);
8731 prt(format(" %s Extract essence", (menu_line == 2) ? "> " : " "), 3, 14);
8732 prt(format(" %s Remove essence", (menu_line == 3) ? "> " : " "), 4, 14);
8733 prt(format(" %s Add essence", (menu_line == 4) ? "> " : " "), 5, 14);
8734 prt(format(" %s Enchant weapon/armor", (menu_line == 5) ? "> " : " "), 6, 14);
8735 prt(format("Choose command from menu."), 0, 0);
8762 if (menu_line > 5) menu_line -= 5;
8771 prt(" a) エッセンス一覧", 2, 14);
8772 prt(" b) エッセンス抽出", 3, 14);
8773 prt(" c) エッセンス消去", 4, 14);
8774 prt(" d) エッセンス付加", 5, 14);
8775 prt(" e) 武器/防具強化", 6, 14);
8776 if (!get_com(format("どの能力を%sますか:", only_browse ? "調べ" : "使い"), &choice, TRUE))
8778 prt(" a) List essences", 2, 14);
8779 prt(" b) Extract essence", 3, 14);
8780 prt(" c) Remove essence", 4, 14);
8781 prt(" d) Add essence", 5, 14);
8782 prt(" e) Enchant weapon/armor", 6, 14);
8783 if (!get_com("Command :", &choice, TRUE))
8820 /* Clear lines, position cursor (really should use strlen here) */
8821 Term_erase(14, 21, 255);
8822 Term_erase(14, 20, 255);
8823 Term_erase(14, 19, 255);
8824 Term_erase(14, 18, 255);
8825 Term_erase(14, 17, 255);
8826 Term_erase(14, 16, 255);
8828 roff_to_buf(kaji_tips[mode-1], 62, temp, sizeof(temp));
8829 for(j=0, line = 17;temp[j];j+=(1+strlen(&temp[j])))
8831 prt(&temp[j], line, 15);
8836 if (!only_browse) screen_load();
8837 } while (only_browse);
8841 #endif /* ALLOW_REPEAT */
8845 case 1: display_essence();break;
8846 case 2: drain_essence();break;
8847 case 3: erase_essence();break;
8849 mode = choose_essence();
8854 case 5: add_essence(10);break;
8860 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
8861 * Torches have special abilities when they are flaming.
8862 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8863 * @param flgs 特別に追加するフラグを返す参照ポインタ
8866 void torch_flags(object_type *o_ptr, u32b *flgs)
8868 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8870 if (o_ptr->xtra4 > 0)
8872 add_flag(flgs, TR_BRAND_FIRE);
8873 add_flag(flgs, TR_KILL_UNDEAD);
8874 add_flag(flgs, TR_THROW);
8880 * @brief 投擲時たいまつにダイスを与える。
8881 * Torches have special abilities when they are flaming.
8882 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8883 * @param dd 特別なダイス数を返す参照ポインタ
8884 * @param ds 特別なダイス面数を返す参照ポインタ
8887 void torch_dice(object_type *o_ptr, int *dd, int *ds)
8889 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8891 if (o_ptr->xtra4 > 0)
8900 * @brief 投擲時命中したたいまつの寿命を縮める。
8901 * Torches have special abilities when they are flaming.
8902 * @param o_ptr 投擲するオブジェクトの構造体参照ポインタ
8905 void torch_lost_fuel(object_type *o_ptr)
8907 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
8909 o_ptr->xtra4 -= (FUEL_TORCH / 25);
8910 if (o_ptr->xtra4 < 0) o_ptr->xtra4 = 0;